Turning on OSPF

Step 1: start the process

router ospf 1 starts OSPF process 1. The number only matters inside this router: neighbours don't need the same process number.

Step 2: set the router ID

router-id 1.1.1.1. If you don't set one, the router picks one itself:

  1. the router-id command, if there is one;
  2. else the highest IP address on a loopback interface that is up;
  3. else the highest IP address on any interface that is up.

Setting it by hand keeps it stable and easy to read.

Step 3: choose the interfaces

A network command turns OSPF on for every interface whose address matches, and puts it in an area:

network 10.0.12.0 0.0.0.3 area 0

The second number is a wildcard mask: the opposite of a subnet mask. A 0 bit means "must match", a 1 bit means "don't care". To turn a subnet mask into a wildcard, take it away from 255.255.255.255:

Subnet maskWildcardMatches
255.255.255.255 (/32)0.0.0.0Exactly one address
255.255.255.252 (/30)0.0.0.34 addresses
255.255.255.0 (/24)0.0.0.255A /24
255.0.0.0 (/8)0.255.255.255Everything starting 10. (for network 10.0.0.0)

Or turn OSPF on directly on the interface: ip ospf 1 area 0. Both work; the interface command is clearer, the network command can cover many interfaces at once.

Step 4: passive interfaces

There are no routers on a LAN with only PCs, so there's no point sending hellos there (and it's a security risk: anyone could plug in a router). passive-interface g0/0 stops hellos on that interface, but OSPF still advertises its network.

Here R2 and R3 are already set up. Configure R1 and watch the neighbours come up:

In NetLab

▶ R1
R1>enable
R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 10.0.12.0 0.0.0.3 area 0
*Mar  1 00:00:05.000: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on GigabitEthernet0/1 from LOADING to FULL, Loading Done
R1(config-router)#network 10.0.13.0 0.0.0.3 area 0
*Mar  1 00:00:06.000: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on GigabitEthernet0/2 from LOADING to FULL, Loading Done
R1(config-router)#passive-interface g0/0
R1(config-router)#exit
R1(config)#interface g0/0
R1(config-if)#ip ospf 1 area 0
R1(config-if)#interface loopback0
R1(config-if)#ip ospf 1 area 0
R1(config-if)#end
*Mar  1 00:00:13.000: %SYS-5-CONFIG_I: Configured from console by console
R1#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo0          1     0               1.1.1.1/32         1     LOOP  0/0
Gi0/0        1     0               192.168.1.1/24     1     DR    0/0
Gi0/1        1     0               10.0.12.1/30       1     BDR   1/1
Gi0/2        1     0               10.0.13.1/30       1     BDR   1/1
R1#show ip protocols
*** IP Routing is NSF aware ***

Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 1.1.1.1
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    10.0.12.0 0.0.0.3 area 0
    10.0.13.0 0.0.0.3 area 0
  Routing on Interfaces Configured Explicitly (Area 0):
    GigabitEthernet0/0
    Loopback0
  Passive Interface(s):
    GigabitEthernet0/0
  Routing Information Sources:
    Gateway         Distance      Last Update
    2.2.2.2             110      00:00:10
    3.3.3.3             110      00:00:10
  Distance: (default is 110)

Tip: passive-interface default makes every interface passive; then no passive-interface g0/1 turns hellos back on just where you have neighbours. Handy on routers with many LANs.

Common mistake: A network command doesn't say which networks to advertise: it picks interfaces. An interface whose address doesn't match any network command isn't in OSPF at all.

HOME LABS COMMUNITY DASHBOARD