---
title: OSPF Basic Configuration
slug: enterprise-v5p2/ospf-basic-configuration
createdAt: 2025-12-02T11:41:12.584Z
---

# <font color="#1d50a2">Introduction</font>

OSPF (Open Shortest Path First) is an Interior Gateway Protocol (IGP) used for making routing decisions within a single Autonomous System (AS). It is an implementation of a link-state routing protocol and operates within the context of an Autonomous System. Currently, OSPF Version 2 (RFC2328) is used for IPv4 protocol, while OSPF Version 3 (RFC2740) is used for IPv6 protocol. In this document, OSPF refers to OSPF Version 2.

# <font color="#1d50a2">Configuration Example</font>

<font color="#1d50a2">**Network requirements**</font>

There are three switches in the network. Now we need to achieve interoperability between the three switches, and later we can continue to expand the whole network based on SwitchA and SwitchB as the main service devices.

::Image[]{src="https://app.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/_8HZJTEfyBjSsQFP33NVa-20251202-114241.png" size="80" width="799" height="163" position="center" showCaption="false"}

<font color="#1d50a2">**Procedure** </font>

1. Configure the VLAN to which each interface belongs
   \# Device A

```text
sonic(config)# vlan 100
sonic(config)# interface ethernet 50
sonic(config-if-50)# switchport access vlan 100
```

:::Paragraph{indent="1"}
\# Device B
:::

```text
sonic(config)# vlan 100
sonic(config)# vlan 200
sonic(config)# interface ethernet 50
sonic(config-if-50)# switchport access vlan 100
sonic(config)# interface ethernet 49
sonic(config-if-49)# switchport access vlan 200
```

:::Paragraph{indent="1"}
\# Device C
:::

```text
sonic(config)# vlan 200
sonic(config)# interface ethernet 49
sonic(config-if-49)# switchport access vlan 200
```

2. Configure the IP address of each VLAN interface
   \# Device A

```text
sonic(config)# interface vlan 100
sonic(config-vlanif-100)# ip address 30.0.0.2/30
```

:::Paragraph{indent="1"}
\# Device B
:::

```text
sonic(config)# interface vlan 100
sonic(config-vlanif-100)# ip address 30.0.0.1/30
sonic(config)# interface vlan 200
sonic(config-vlanif-200)# ip address 20.0.0.1/30
```

:::Paragraph{indent="1"}
\# Device C
:::

```text
sonic(config)# interface vlan 200
sonic(config-vlanif-200)# ip address 20.0.0.2/30
```

3. Configuring OSPF Basic Features
   \# Device A

```text
sonic(config)# router ospf
sonic(config-router)# network 30.0.0.1/30 area 2
```

:::Paragraph{indent="1"}
\#Device B:
:::

```text
sonic(config)# router ospf
sonic(config-router)# network 20.0.0.2/30 area 2
sonic(config-router)# network 30.0.0.2/30 area 1
```

:::Paragraph{indent="1"}
\#Device C:
:::

```text
sonic(config)# router ospf
sonic(config-router)# network 20.0.0.1/30 area 1
```

<font color="#1d50a2">**Verify configuration**</font>&#x20;

Take Device B as an example to check the neighbor table

```text
sonic# show ip ospf neighbor
Neighbor ID Pri State   Dead Time Address  Interface   RXmtL RqstL DBsmL
10.15.96.5  1  Full/Backup 38.317s 20.0.0.2 Ethernet49:30.11.13.22 0  0  0
10.15.96.5  1  Full/Backup 32.958s 30.0.0.2 Ethernet50:30.11.13.26 0  0  0
```

##

