OSPF today

Prepare quagga

Step 1 copy lib file for ospf

As most of the libs were copied already with previous assignments. The only lib we have to copy here is libospf.so.0 . Then we are done here with copying

Step 2 change the // daemon // file and test run

We have to change the daemon file of quagga. It controls which daemons are going to run automatically.

Now the daemon file look like this

zebra=yes #alway run
bgpd=no
ospfd=yes #run ospf
ospf6d=no
ripd=no
ripngd=no
isisd=no

It is possible to run multiple routing protocol, but we do not have to make things that complicated here.

Now try to run a test config

+ start script of test. 2 switches, 2 sniffers, 1 host and 1 ospf router (partial setting for network1)
  + <code bash>

#!/bin/sh

#start switches in hub mode first ./netstart start hub sw123 ./netstart start hub sw1

#start sniffers ./netstart start sniffer sniffer123 sw123 ./netstart start sniffer sniffer1 sw1

sleep 10 #start hosts ./netstart start host host1 sw1 10.1.0.2 255.255.0.0 10.1.255.255 10.1.0.1

#start routers ./netstart start router router1 sw1 10.1.0.1 255.255.0.0 10.1.255.255 sw123 10.0.0.1 255.255.224.0 10.0.31.255 ospf </code>

The host script is slight revised

      if [ $pro = "ospf" ]; then
        cp ~/uml/etc/quagga/ospf$hostname.conf ~/uml/etc/quagga/ospfd.conf
      fi
      echo "hold 10 seconds before the router is fully started"
      sleep 10
      echo "router $hostname started"

The above if cluster is added. And the sleep 10 seconds is kind of important. As if the router starts too fast, the later server can read the config from the earlier one, or vice verser.

feedback of the host script

vic@vicubuntu:~$ sudo ./ospf 
[sudo] password for vic: 
hub sw123 started
hub sw1 started
sniffer: sniffer123 conneted to switch: sw123
sniffer: sniffer1 conneted to switch: sw1
host host1 started
hold 10 seconds before the router is fully started
router router1 started

now try telnet within the router

Starting Quagga daemons (prio:10): zebra ospfd.
INFO: ospf  started
 
/ # telnet 0 2604
 
Entering character mode
Escape character is '^]'.
 
 
Hello, this is Quagga (version 0.99.15).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
 
 
User Access Verification

It is working!!!

Setup network1

Picture of network 1, ip scheme and ip assignment per port

+ config file to start network 1
  + <code bash>

#!/bin/sh

#start switches in hub mode first ./netstart start hub sw123 ./netstart start hub sw14 ./netstart start hub sw35 ./netstart start hub sw45 ./netstart start hub sw1 ./netstart start hub sw2 ./netstart start hub sw3 ./netstart start hub sw4 ./netstart start hub sw5

#start sniffers ./netstart start sniffer sniffer123 sw123 ./netstart start sniffer sniffer14 sw14 ./netstart start sniffer sniffer35 sw35 ./netstart start sniffer sniffer45 sw45 ./netstart start sniffer sniffer1 sw1 ./netstart start sniffer sniffer2 sw2 ./netstart start sniffer sniffer3 sw3 ./netstart start sniffer sniffer4 sw4 ./netstart start sniffer sniffer5 sw5

sleep 10

#start routers ./netstart start router router1 \ sw1 10.1.0.1 255.255.0.0 10.1.255.255 \ sw123 10.0.0.1 255.255.240.0 10.0.15.255 \ sw14 192.168.30.1 255.255.255.252 192.168.30.3 \ ospf

./netstart start router router2 \ sw2 10.2.0.1 255.255.0.0 10.2.255.255 \ sw123 10.0.0.2 255.255.240.0 10.0.15.255 \ ospf

./netstart start router router3 \ sw3 10.3.0.1 255.255.0.0 10.3.255.255 \ sw123 10.0.0.3 255.255.240.0 10.0.15.255 \ sw35 172.16.5.1 255.255.255.252 172.16.5.3 \ ospf

./netstart start router router4 \ sw4 10.4.0.1 255.255.0.0 10.4.255.255 \ sw14 192.168.30.2 255.255.255.252 192.168.30.3 \ sw45 192.168.30.5 255.255.255.252 192.168.30.7 \ ospf

./netstart start router router5 \ sw5 10.5.0.1 255.255.0.0 10.5.255.255 \ sw35 172.16.5.2 255.255.255.252 172.16.5.3 \ sw45 192.168.30.6 255.255.255.252 192.168.30.7 \ ospf

screen -ls </code>

+ routing information from router 1
  + <code bash>

/ # ip route 192.168.30.4/30 via 192.168.30.2 dev eth2 metric 20 192.168.30.0/30 dev eth2 src 192.168.30.1 172.16.5.0/30 via 10.0.0.3 dev eth1 metric 20 10.0.0.0/20 dev eth1 src 10.0.0.1 10.2.0.0/16 via 10.0.0.2 dev eth1 metric 20 10.3.0.0/16 via 10.0.0.3 dev eth1 metric 20 10.1.0.0/16 dev eth0 src 10.1.0.1 10.4.0.0/16 via 192.168.30.2 dev eth2 metric 20 10.5.0.0/16 metric 30

#ospf info ospfd1# sh ip o OSPF Routing Process, Router ID: 192.168.30.1 Supports only single TOS (TOS0) routes This implementation conforms to RFC2328 RFC1583Compatibility flag is disabled OpaqueCapability flag is disabled Initial SPF scheduling delay 200 millisec(s) Minimum hold time between consecutive SPFs 1000 millisec(s) Maximum hold time between consecutive SPFs 10000 millisec(s) Hold time multiplier is currently 1 SPF algorithm last executed 8m03s ago SPF timer is inactive Refresh timer 10 secs This router is an ASBR (injecting external routing information) Number of external LSA 0. Checksum Sum 0x00000000 Number of opaque AS LSA 0. Checksum Sum 0x00000000 Number of areas attached to this router: 1

Area ID: 0.0.0.0 (Backbone)

 Number of interfaces in this area: Total: 3, Active: 3
 Number of fully adjacent neighbors in this area: 3
 Area has no authentication
 SPF algorithm executed 9 times
 Number of LSA 9
 Number of router LSA 5. Checksum Sum 0x0002128c
 Number of network LSA 4. Checksum Sum 0x0000c8cb
 Number of summary LSA 0. Checksum Sum 0x00000000
 Number of ASBR summary LSA 0. Checksum Sum 0x00000000
 Number of NSSA LSA 0. Checksum Sum 0x00000000
 Number of opaque link LSA 0. Checksum Sum 0x00000000
 Number of opaque area LSA 0. Checksum Sum 0x00000000

#ospf neighbor info ospfd1# sh ip o n

  Neighbor ID Pri State           Dead Time Address         Interface            RXmtL RqstL DBsmL

10.0.0.2 1 Full/DROther 35.672s 10.0.0.2 eth1:10.0.0.1 0 0 0 172.16.5.1 1 Full/Backup 35.672s 10.0.0.3 eth1:10.0.0.1 0 0 0 192.168.30.5 1 Full/Backup 35.673s 192.168.30.2 eth2:192.168.30.1 0 0 0

#ospf database info ospfd1# sh ip o d

     OSPF Router with ID (192.168.30.1)
              Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count 10.0.0.2 10.0.0.2 562 0x80000004 0x4aa5 2 172.16.5.1 172.16.5.1 538 0x80000005 0x8956 3 192.168.30.1 192.168.30.1 557 0x80000005 0x4c81 3 192.168.30.5 192.168.30.5 538 0x80000006 0xdfdc 3 192.168.30.6 192.168.30.6 539 0x80000003 0x1234 3

              Net Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum 10.0.0.1 192.168.30.1 557 0x80000002 0x7ff9 172.16.5.2 192.168.30.6 544 0x80000001 0x18a3 192.168.30.1 192.168.30.1 582 0x80000001 0x2512 192.168.30.6 192.168.30.6 544 0x80000001 0x0b1d

#ospf interface info ospfd1# sh ip o i eth0 is up

ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.1.0.1/16, Broadcast 10.1.255.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.30.1, Interface Address 10.1.0.1
No backup designated router on this network
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 5.478s
Neighbor Count is 0, Adjacent neighbor count is 0

eth1 is up

ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.0.0.1/20, Broadcast 10.0.15.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.30.1, Interface Address 10.0.0.1
Backup Designated Router (ID) 172.16.5.1, Interface Address 10.0.0.3
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 5.478s
Neighbor Count is 2, Adjacent neighbor count is 2

eth2 is up

ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 192.168.30.1/30, Broadcast 192.168.30.3, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.30.1, Interface Address 192.168.30.1
Backup Designated Router (ID) 192.168.30.5, Interface Address 192.168.30.2
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 5.479s
Neighbor Count is 1, Adjacent neighbor count is 1

lo is up

ifindex 1, MTU 16436 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
OSPF not enabled on this interface

#ospf route info ospfd1# sh ip o r

OSPF network routing table

N 10.0.0.0/20 [10] area: 0.0.0.0

                         directly attached to eth1

N 10.1.0.0/16 [10] area: 0.0.0.0

                         directly attached to eth0

N 10.2.0.0/16 [20] area: 0.0.0.0

                         via 10.0.0.2, eth1

N 10.3.0.0/16 [20] area: 0.0.0.0

                         via 10.0.0.3, eth1

N 10.4.0.0/16 [20] area: 0.0.0.0

                         via 192.168.30.2, eth2

N 10.5.0.0/16 [30] area: 0.0.0.0

                         via 10.0.0.3, eth1
                         via 192.168.30.2, eth2

N 172.16.5.0/30 [20] area: 0.0.0.0

                         via 10.0.0.3, eth1

N 192.168.30.0/30 [10] area: 0.0.0.0

                         directly attached to eth2

N 192.168.30.4/30 [20] area: 0.0.0.0

                         via 192.168.30.2, eth2

OSPF router routing table

R 10.0.0.2 [10] area: 0.0.0.0, ASBR

                         via 10.0.0.2, eth1

R 172.16.5.1 [10] area: 0.0.0.0, ASBR

                         via 10.0.0.3, eth1

R 192.168.30.5 [10] area: 0.0.0.0, ASBR

                         via 192.168.30.2, eth2

R 192.168.30.6 [20] area: 0.0.0.0, ASBR

                         via 10.0.0.3, eth1
                         via 192.168.30.2, eth2

OSPF external routing table

</code>

+ routing info from router 2
  + <code bash>

/ # ip route 192.168.30.4/30 metric 30 192.168.30.0/30 via 10.0.0.1 dev eth1 metric 20 172.16.5.0/30 via 10.0.0.3 dev eth1 metric 20 10.0.0.0/20 dev eth1 src 10.0.0.2 10.2.0.0/16 dev eth0 src 10.2.0.1 10.3.0.0/16 via 10.0.0.3 dev eth1 metric 20 10.1.0.0/16 via 10.0.0.1 dev eth1 metric 20 10.4.0.0/16 via 10.0.0.1 dev eth1 metric 30 10.5.0.0/16 via 10.0.0.3 dev eth1 metric 30

#ospf info ospfd2# sh ip o OSPF Routing Process, Router ID: 10.0.0.2 Supports only single TOS (TOS0) routes This implementation conforms to RFC2328 RFC1583Compatibility flag is disabled OpaqueCapability flag is disabled Initial SPF scheduling delay 200 millisec(s) Minimum hold time between consecutive SPFs 1000 millisec(s) Maximum hold time between consecutive SPFs 10000 millisec(s) Hold time multiplier is currently 1 SPF algorithm last executed 11m20s ago SPF timer is inactive Refresh timer 10 secs This router is an ASBR (injecting external routing information) Number of external LSA 0. Checksum Sum 0x00000000 Number of opaque AS LSA 0. Checksum Sum 0x00000000 Number of areas attached to this router: 1

Area ID: 0.0.0.0 (Backbone)

 Number of interfaces in this area: Total: 2, Active: 2
 Number of fully adjacent neighbors in this area: 2
 Area has no authentication
 SPF algorithm executed 7 times
 Number of LSA 9
 Number of router LSA 5. Checksum Sum 0x0002128c
 Number of network LSA 4. Checksum Sum 0x0000c8cb
 Number of summary LSA 0. Checksum Sum 0x00000000
 Number of ASBR summary LSA 0. Checksum Sum 0x00000000
 Number of NSSA LSA 0. Checksum Sum 0x00000000
 Number of opaque link LSA 0. Checksum Sum 0x00000000
 Number of opaque area LSA 0. Checksum Sum 0x00000000

#ospf database info ospfd2# sh ip o border-routers database interface neighbor route ospfd2# sh ip o d

     OSPF Router with ID (10.0.0.2)
              Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count 10.0.0.2 10.0.0.2 744 0x80000004 0x4aa5 2 172.16.5.1 172.16.5.1 720 0x80000005 0x8956 3 192.168.30.1 192.168.30.1 740 0x80000005 0x4c81 3 192.168.30.5 192.168.30.5 721 0x80000006 0xdfdc 3 192.168.30.6 192.168.30.6 721 0x80000003 0x1234 3

              Net Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum 10.0.0.1 192.168.30.1 740 0x80000002 0x7ff9 172.16.5.2 192.168.30.6 727 0x80000001 0x18a3 192.168.30.1 192.168.30.1 764 0x80000001 0x2512 192.168.30.6 192.168.30.6 727 0x80000001 0x0b1d

#ospf interface info ospfd2# sh ip o i eth0 is up

ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.2.0.1/16, Broadcast 10.2.255.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 10.0.0.2, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 10.0.0.2, Interface Address 10.2.0.1
No backup designated router on this network
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 5.473s
Neighbor Count is 0, Adjacent neighbor count is 0

eth1 is up

ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.0.0.2/20, Broadcast 10.0.15.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 10.0.0.2, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DROther, Priority 1
Designated Router (ID) 192.168.30.1, Interface Address 10.0.0.1
Backup Designated Router (ID) 172.16.5.1, Interface Address 10.0.0.3
Multicast group memberships: OSPFAllRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 5.474s
Neighbor Count is 2, Adjacent neighbor count is 2

lo is up

ifindex 1, MTU 16436 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
OSPF not enabled on this interface

#ospf neighbor info ospfd2# sh ip o n

  Neighbor ID Pri State           Dead Time Address         Interface            RXmtL RqstL DBsmL

192.168.30.1 1 Full/DR 39.437s 10.0.0.1 eth1:10.0.0.2 0 0 0 172.16.5.1 1 Full/Backup 39.437s 10.0.0.3 eth1:10.0.0.2 0 0 0

#ospf route info ospfd2# sh ip o r

OSPF network routing table

N 10.0.0.0/20 [10] area: 0.0.0.0

                         directly attached to eth1

N 10.1.0.0/16 [20] area: 0.0.0.0

                         via 10.0.0.1, eth1

N 10.2.0.0/16 [10] area: 0.0.0.0

                         directly attached to eth0

N 10.3.0.0/16 [20] area: 0.0.0.0

                         via 10.0.0.3, eth1

N 10.4.0.0/16 [30] area: 0.0.0.0

                         via 10.0.0.1, eth1

N 10.5.0.0/16 [30] area: 0.0.0.0

                         via 10.0.0.3, eth1

N 172.16.5.0/30 [20] area: 0.0.0.0

                         via 10.0.0.3, eth1

N 192.168.30.0/30 [20] area: 0.0.0.0

                         via 10.0.0.1, eth1

N 192.168.30.4/30 [30] area: 0.0.0.0

                         via 10.0.0.1, eth1
                         via 10.0.0.3, eth1

OSPF router routing table

R 172.16.5.1 [10] area: 0.0.0.0, ASBR

                         via 10.0.0.3, eth1

R 192.168.30.1 [10] area: 0.0.0.0, ASBR

                         via 10.0.0.1, eth1

R 192.168.30.5 [20] area: 0.0.0.0, ASBR

                         via 10.0.0.1, eth1

R 192.168.30.6 [20] area: 0.0.0.0, ASBR

                         via 10.0.0.3, eth1

OSPF external routing table

</code>

+ routing info from router 3
  + <code bash>

/ # ip route 192.168.30.4/30 via 172.16.5.2 dev eth2 metric 20 192.168.30.0/30 via 10.0.0.1 dev eth1 metric 20 172.16.5.0/30 dev eth2 src 172.16.5.1 10.0.0.0/20 dev eth1 src 10.0.0.3 10.2.0.0/16 via 10.0.0.2 dev eth1 metric 20 10.3.0.0/16 dev eth0 src 10.3.0.1 10.1.0.0/16 via 10.0.0.1 dev eth1 metric 20 10.4.0.0/16 metric 30 10.5.0.0/16 via 172.16.5.2 dev eth2 metric 20

#ospf info ospfd3# sh ip o OSPF Routing Process, Router ID: 172.16.5.1 Supports only single TOS (TOS0) routes This implementation conforms to RFC2328 RFC1583Compatibility flag is disabled OpaqueCapability flag is disabled Initial SPF scheduling delay 200 millisec(s) Minimum hold time between consecutive SPFs 1000 millisec(s) Maximum hold time between consecutive SPFs 10000 millisec(s) Hold time multiplier is currently 1 SPF algorithm last executed 14m28s ago SPF timer is inactive Refresh timer 10 secs This router is an ASBR (injecting external routing information) Number of external LSA 0. Checksum Sum 0x00000000 Number of opaque AS LSA 0. Checksum Sum 0x00000000 Number of areas attached to this router: 1

Area ID: 0.0.0.0 (Backbone)

 Number of interfaces in this area: Total: 3, Active: 3
 Number of fully adjacent neighbors in this area: 3
 Area has no authentication
 SPF algorithm executed 6 times
 Number of LSA 9
 Number of router LSA 5. Checksum Sum 0x0002128c
 Number of network LSA 4. Checksum Sum 0x0000c8cb
 Number of summary LSA 0. Checksum Sum 0x00000000
 Number of ASBR summary LSA 0. Checksum Sum 0x00000000
 Number of NSSA LSA 0. Checksum Sum 0x00000000
 Number of opaque link LSA 0. Checksum Sum 0x00000000
 Number of opaque area LSA 0. Checksum Sum 0x00000000

#ospf database info ospfd3# sh ip o d

     OSPF Router with ID (172.16.5.1)
              Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count 10.0.0.2 10.0.0.2 911 0x80000004 0x4aa5 2 172.16.5.1 172.16.5.1 885 0x80000005 0x8956 3 192.168.30.1 192.168.30.1 906 0x80000005 0x4c81 3 192.168.30.5 192.168.30.5 887 0x80000006 0xdfdc 3 192.168.30.6 192.168.30.6 886 0x80000003 0x1234 3

              Net Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum 10.0.0.1 192.168.30.1 906 0x80000002 0x7ff9 172.16.5.2 192.168.30.6 891 0x80000001 0x18a3 192.168.30.1 192.168.30.1 931 0x80000001 0x2512 192.168.30.6 192.168.30.6 891 0x80000001 0x0b1d

#ospf neighbor info ospfd3# sh ip o n

  Neighbor ID Pri State           Dead Time Address         Interface            RXmtL RqstL DBsmL

192.168.30.1 1 Full/DR 34.173s 10.0.0.1 eth1:10.0.0.3 0 0 0 10.0.0.2 1 Full/DROther 34.181s 10.0.0.2 eth1:10.0.0.3 0 0 0 192.168.30.6 1 Full/DR 34.174s 172.16.5.2 eth2:172.16.5.1 0 0 0

#ospf interface info ospfd3# sh ip o i eth0 is up

ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.3.0.1/16, Broadcast 10.3.255.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 172.16.5.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 172.16.5.1, Interface Address 10.3.0.1
No backup designated router on this network
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 4.074s
Neighbor Count is 0, Adjacent neighbor count is 0

eth1 is up

ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.0.0.3/20, Broadcast 10.0.15.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 172.16.5.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State Backup, Priority 1
Designated Router (ID) 192.168.30.1, Interface Address 10.0.0.1
Backup Designated Router (ID) 172.16.5.1, Interface Address 10.0.0.3
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 4.074s
Neighbor Count is 2, Adjacent neighbor count is 2

eth2 is up

ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 172.16.5.1/30, Broadcast 172.16.5.3, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 172.16.5.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State Backup, Priority 1
Designated Router (ID) 192.168.30.6, Interface Address 172.16.5.2
Backup Designated Router (ID) 172.16.5.1, Interface Address 172.16.5.1
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 4.074s
Neighbor Count is 1, Adjacent neighbor count is 1

lo is up

ifindex 1, MTU 16436 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
OSPF not enabled on this interface

#ospf route info ospfd3# sh ip o r

OSPF network routing table

N 10.0.0.0/20 [10] area: 0.0.0.0

                         directly attached to eth1

N 10.1.0.0/16 [20] area: 0.0.0.0

                         via 10.0.0.1, eth1

N 10.2.0.0/16 [20] area: 0.0.0.0

                         via 10.0.0.2, eth1

N 10.3.0.0/16 [10] area: 0.0.0.0

                         directly attached to eth0

N 10.4.0.0/16 [30] area: 0.0.0.0

                         via 10.0.0.1, eth1
                         via 172.16.5.2, eth2

N 10.5.0.0/16 [20] area: 0.0.0.0

                         via 172.16.5.2, eth2

N 172.16.5.0/30 [10] area: 0.0.0.0

                         directly attached to eth2

N 192.168.30.0/30 [20] area: 0.0.0.0

                         via 10.0.0.1, eth1

N 192.168.30.4/30 [20] area: 0.0.0.0

                         via 172.16.5.2, eth2

OSPF router routing table

R 10.0.0.2 [10] area: 0.0.0.0, ASBR

                         via 10.0.0.2, eth1

R 192.168.30.1 [10] area: 0.0.0.0, ASBR

                         via 10.0.0.1, eth1

R 192.168.30.5 [20] area: 0.0.0.0, ASBR

                         via 10.0.0.1, eth1
                         via 172.16.5.2, eth2

R 192.168.30.6 [10] area: 0.0.0.0, ASBR

                         via 172.16.5.2, eth2

OSPF external routing table

</code>

+ routing info from router 4
  + <code bash>

/ # ip route 192.168.30.4/30 dev eth2 src 192.168.30.5 192.168.30.0/30 dev eth1 src 192.168.30.2 172.16.5.0/30 via 192.168.30.6 dev eth2 metric 20 10.0.0.0/20 via 192.168.30.1 dev eth1 metric 20 10.2.0.0/16 via 192.168.30.1 dev eth1 metric 30 10.3.0.0/16 metric 30 10.1.0.0/16 via 192.168.30.1 dev eth1 metric 20 10.4.0.0/16 dev eth0 src 10.4.0.1 10.5.0.0/16 via 192.168.30.6 dev eth2 metric 20

#ospf info ospfd4# sh ip o OSPF Routing Process, Router ID: 192.168.30.5 Supports only single TOS (TOS0) routes This implementation conforms to RFC2328 RFC1583Compatibility flag is disabled OpaqueCapability flag is disabled Initial SPF scheduling delay 200 millisec(s) Minimum hold time between consecutive SPFs 1000 millisec(s) Maximum hold time between consecutive SPFs 10000 millisec(s) Hold time multiplier is currently 1 SPF algorithm last executed 16m49s ago SPF timer is inactive Refresh timer 10 secs This router is an ASBR (injecting external routing information) Number of external LSA 0. Checksum Sum 0x00000000 Number of opaque AS LSA 0. Checksum Sum 0x00000000 Number of areas attached to this router: 1

Area ID: 0.0.0.0 (Backbone)

 Number of interfaces in this area: Total: 3, Active: 3
 Number of fully adjacent neighbors in this area: 2
 Area has no authentication
 SPF algorithm executed 9 times
 Number of LSA 9
 Number of router LSA 5. Checksum Sum 0x0002128c
 Number of network LSA 4. Checksum Sum 0x0000c8cb
 Number of summary LSA 0. Checksum Sum 0x00000000
 Number of ASBR summary LSA 0. Checksum Sum 0x00000000
 Number of NSSA LSA 0. Checksum Sum 0x00000000
 Number of opaque link LSA 0. Checksum Sum 0x00000000
 Number of opaque area LSA 0. Checksum Sum 0x00000000

#ospf database ospfd4# sh ip ospf d

     OSPF Router with ID (192.168.30.5)
              Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count 10.0.0.2 10.0.0.2 1050 0x80000004 0x4aa5 2 172.16.5.1 172.16.5.1 1026 0x80000005 0x8956 3 192.168.30.1 192.168.30.1 1045 0x80000005 0x4c81 3 192.168.30.5 192.168.30.5 1024 0x80000006 0xdfdc 3 192.168.30.6 192.168.30.6 1027 0x80000003 0x1234 3

              Net Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum 10.0.0.1 192.168.30.1 1045 0x80000002 0x7ff9 172.16.5.2 192.168.30.6 1030 0x80000001 0x18a3 192.168.30.1 192.168.30.1 1070 0x80000001 0x2512 192.168.30.6 192.168.30.6 1030 0x80000001 0x0b1d

#ospf interface ospfd4# sh ip ospf i eth0 is up

ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.4.0.1/16, Broadcast 10.4.255.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.5, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.30.5, Interface Address 10.4.0.1
No backup designated router on this network
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 3.908s
Neighbor Count is 0, Adjacent neighbor count is 0

eth1 is up

ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 192.168.30.2/30, Broadcast 192.168.30.3, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.5, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State Backup, Priority 1
Designated Router (ID) 192.168.30.1, Interface Address 192.168.30.1
Backup Designated Router (ID) 192.168.30.5, Interface Address 192.168.30.2
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 3.908s
Neighbor Count is 1, Adjacent neighbor count is 1

eth2 is up

ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 192.168.30.5/30, Broadcast 192.168.30.7, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.5, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State Backup, Priority 1
Designated Router (ID) 192.168.30.6, Interface Address 192.168.30.6
Backup Designated Router (ID) 192.168.30.5, Interface Address 192.168.30.5
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 3.909s
Neighbor Count is 1, Adjacent neighbor count is 1

lo is up

ifindex 1, MTU 16436 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
OSPF not enabled on this interface

#ospf neighbor ospfd4# sh ip ospf n

  Neighbor ID Pri State           Dead Time Address         Interface            RXmtL RqstL DBsmL

192.168.30.1 1 Full/DR 37.842s 192.168.30.1 eth1:192.168.30.2 0 0 0 192.168.30.6 1 Full/DR 37.837s 192.168.30.6 eth2:192.168.30.5 0 0 0

#ospf route ospfd4# sh ip ospf r

OSPF network routing table

N 10.0.0.0/20 [20] area: 0.0.0.0

                         via 192.168.30.1, eth1

N 10.1.0.0/16 [20] area: 0.0.0.0

                         via 192.168.30.1, eth1

N 10.2.0.0/16 [30] area: 0.0.0.0

                         via 192.168.30.1, eth1

N 10.3.0.0/16 [30] area: 0.0.0.0

                         via 192.168.30.1, eth1
                         via 192.168.30.6, eth2

N 10.4.0.0/16 [10] area: 0.0.0.0

                         directly attached to eth0

N 10.5.0.0/16 [20] area: 0.0.0.0

                         via 192.168.30.6, eth2

N 172.16.5.0/30 [20] area: 0.0.0.0

                         via 192.168.30.6, eth2

N 192.168.30.0/30 [10] area: 0.0.0.0

                         directly attached to eth1

N 192.168.30.4/30 [10] area: 0.0.0.0

                         directly attached to eth2

OSPF router routing table

R 10.0.0.2 [20] area: 0.0.0.0, ASBR

                         via 192.168.30.1, eth1

R 172.16.5.1 [20] area: 0.0.0.0, ASBR

                         via 192.168.30.1, eth1
                         via 192.168.30.6, eth2

R 192.168.30.1 [10] area: 0.0.0.0, ASBR

                         via 192.168.30.1, eth1

R 192.168.30.6 [10] area: 0.0.0.0, ASBR

                         via 192.168.30.6, eth2

OSPF external routing table

</code>

+ routing info from router 5
  + <code bash>

/ # ip route 192.168.30.4/30 dev eth2 src 192.168.30.6 192.168.30.0/30 via 192.168.30.5 dev eth2 metric 20 172.16.5.0/30 dev eth1 src 172.16.5.2 10.0.0.0/20 via 172.16.5.1 dev eth1 metric 20 10.2.0.0/16 via 172.16.5.1 dev eth1 metric 30 10.3.0.0/16 via 172.16.5.1 dev eth1 metric 20 10.1.0.0/16 metric 30 10.4.0.0/16 via 192.168.30.5 dev eth2 metric 20 10.5.0.0/16 dev eth0 src 10.5.0.1

#ospf info ospfd5# sh ip o OSPF Routing Process, Router ID: 192.168.30.6 Supports only single TOS (TOS0) routes This implementation conforms to RFC2328 RFC1583Compatibility flag is disabled OpaqueCapability flag is disabled Initial SPF scheduling delay 200 millisec(s) Minimum hold time between consecutive SPFs 1000 millisec(s) Maximum hold time between consecutive SPFs 10000 millisec(s) Hold time multiplier is currently 1 SPF algorithm last executed 19m04s ago SPF timer is inactive Refresh timer 10 secs This router is an ASBR (injecting external routing information) Number of external LSA 0. Checksum Sum 0x00000000 Number of opaque AS LSA 0. Checksum Sum 0x00000000 Number of areas attached to this router: 1

Area ID: 0.0.0.0 (Backbone)

 Number of interfaces in this area: Total: 3, Active: 3
 Number of fully adjacent neighbors in this area: 2
 Area has no authentication
 SPF algorithm executed 3 times
 Number of LSA 9
 Number of router LSA 5. Checksum Sum 0x0002128c
 Number of network LSA 4. Checksum Sum 0x0000c8cb
 Number of summary LSA 0. Checksum Sum 0x00000000
 Number of ASBR summary LSA 0. Checksum Sum 0x00000000
 Number of NSSA LSA 0. Checksum Sum 0x00000000
 Number of opaque link LSA 0. Checksum Sum 0x00000000
 Number of opaque area LSA 0. Checksum Sum 0x00000000

#ospf database ospfd5# sh ip o d

     OSPF Router with ID (192.168.30.6)
              Router Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum Link count 10.0.0.2 10.0.0.2 1194 0x80000004 0x4aa5 2 172.16.5.1 172.16.5.1 1169 0x80000005 0x8956 3 192.168.30.1 192.168.30.1 1190 0x80000005 0x4c81 3 192.168.30.5 192.168.30.5 1170 0x80000006 0xdfdc 3 192.168.30.6 192.168.30.6 1168 0x80000003 0x1234 3

              Net Link States (Area 0.0.0.0)

Link ID ADV Router Age Seq# CkSum 10.0.0.1 192.168.30.1 1190 0x80000002 0x7ff9 172.16.5.2 192.168.30.6 1173 0x80000001 0x18a3 192.168.30.1 192.168.30.1 1214 0x80000001 0x2512 192.168.30.6 192.168.30.6 1173 0x80000001 0x0b1d

#ospf interface ospfd5# sh ip o i eth0 is up

ifindex 2, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 10.5.0.1/16, Broadcast 10.5.255.255, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.6, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.30.6, Interface Address 10.5.0.1
No backup designated router on this network
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 6.981s
Neighbor Count is 0, Adjacent neighbor count is 0

eth1 is up

ifindex 3, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 172.16.5.2/30, Broadcast 172.16.5.3, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.6, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.30.6, Interface Address 172.16.5.2
Backup Designated Router (ID) 172.16.5.1, Interface Address 172.16.5.1
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 6.981s
Neighbor Count is 1, Adjacent neighbor count is 1

eth2 is up

ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 192.168.30.6/30, Broadcast 192.168.30.7, Area 0.0.0.0
MTU mismatch detection:enabled
Router ID 192.168.30.6, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.30.6, Interface Address 192.168.30.6
Backup Designated Router (ID) 192.168.30.5, Interface Address 192.168.30.5
Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
  Hello due in 6.981s
Neighbor Count is 1, Adjacent neighbor count is 1

lo is up

ifindex 1, MTU 16436 bytes, BW 0 Kbit <UP,LOOPBACK,RUNNING>
OSPF not enabled on this interface

#ospf neighbor ospfd5# sh ip o n

  Neighbor ID Pri State           Dead Time Address         Interface            RXmtL RqstL DBsmL

172.16.5.1 1 Full/Backup 30.785s 172.16.5.1 eth1:172.16.5.2 0 0 0 192.168.30.5 1 Full/Backup 30.783s 192.168.30.5 eth2:192.168.30.6 0 0 0

#ospf route ospfd5# sh ip o r

OSPF network routing table

N 10.0.0.0/20 [20] area: 0.0.0.0

                         via 172.16.5.1, eth1

N 10.1.0.0/16 [30] area: 0.0.0.0

                         via 172.16.5.1, eth1
                         via 192.168.30.5, eth2

N 10.2.0.0/16 [30] area: 0.0.0.0

                         via 172.16.5.1, eth1

N 10.3.0.0/16 [20] area: 0.0.0.0

                         via 172.16.5.1, eth1

N 10.4.0.0/16 [20] area: 0.0.0.0

                         via 192.168.30.5, eth2

N 10.5.0.0/16 [10] area: 0.0.0.0

                         directly attached to eth0

N 172.16.5.0/30 [10] area: 0.0.0.0

                         directly attached to eth1

N 192.168.30.0/30 [20] area: 0.0.0.0

                         via 192.168.30.5, eth2

N 192.168.30.4/30 [10] area: 0.0.0.0

                         directly attached to eth2

OSPF router routing table

R 10.0.0.2 [20] area: 0.0.0.0, ASBR

                         via 172.16.5.1, eth1

R 172.16.5.1 [10] area: 0.0.0.0, ASBR

                         via 172.16.5.1, eth1

R 192.168.30.1 [20] area: 0.0.0.0, ASBR

                         via 172.16.5.1, eth1
                         via 192.168.30.5, eth2

R 192.168.30.5 [10] area: 0.0.0.0, ASBR

                         via 192.168.30.5, eth2

OSPF external routing table

</code>

/31 netowrk

It is not difficult to put the two directly connected ports in /31 network

on router 4

ifconfig eth2 192.168.30.4 netmask 255.255.255.254

on router 5

ifconfig eth2 192.168.30.5 netmask 255.255.255.254

However it will not just work. There will not be any traffic in between router 4 and 5 except for the IGMP and hello packet. No ICMP (ping), not data.

Route information learned on router 2, and from router 2, I can ping them both that's because for router 4, the traffic goes through router 3, for router 5 it goes through router 1.

/ # ip route
192.168.30.4/31  metric 30
192.168.30.0/30 via 10.0.0.1 dev eth1  metric 20
172.16.5.0/30 via 10.0.0.3 dev eth1  metric 20
10.0.0.0/20 dev eth1  src 10.0.0.2
10.2.0.0/16 dev eth0  src 10.2.0.1
10.3.0.0/16 via 10.0.0.3 dev eth1  metric 20
10.1.0.0/16 via 10.0.0.1 dev eth1  metric 20
10.4.0.0/16 via 10.0.0.1 dev eth1  metric 30
10.5.0.0/16 via 10.0.0.3 dev eth1  metric 30
/ # ping 192.168.30.4
PING 192.168.30.4 (192.168.30.4): 56 data bytes
64 bytes from 192.168.30.4: seq=0 ttl=63 time=22.131 ms
64 bytes from 192.168.30.4: seq=1 ttl=63 time=0.782 ms
^C
--- 192.168.30.4 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.782/11.456/22.131 ms
/ # ping 192.168.30.5
PING 192.168.30.5 (192.168.30.5): 56 data bytes
64 bytes from 192.168.30.5: seq=0 ttl=63 time=22.035 ms
64 bytes from 192.168.30.5: seq=1 ttl=63 time=0.781 ms
^C
--- 192.168.30.5 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.781/11.408/22.035 ms

we can see that router 4 and 5 are still sending ospf hello packets and taking part in the ospf. but just cannot reach each other.

eth2 is up
  ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.30.4/31, Broadcast 192.168.30.5, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.30.4, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.30.4, Interface Address 192.168.30.4
  No backup designated router on this network
  Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 3.944s
  Neighbor Count is 0, Adjacent neighbor count is 0

As we can see above, the interface is up and working, and talking OSPF, but it is alone in the network. Itself is elected DR and no BDR since it sees itself as the only OSPF router in the network. This is the same on router 5

router 3 can ping router 5 but not router 4. router 1 can ping router 4 not router 5. So the link is only symbolic, it is not transferring any data.

point to pint

For /31 interfaces to work, we have to make it point to point link which we can do by the following command.

ospfd4# conf t
ospfd4(config)# in eth2
ospfd4(config-if)# ip os n point-to-p

The above command will enter the terminal config mode, from there enter the interface config mode, then change the connection type of eth2 to point to point which is needed in our case.

After the config is done, there is no more DR, BDR nor election on the point to point link. But they are still active neighbors.

2163	10786.001563	192.168.30.4	224.0.0.5	OSPF	Hello Packet
 
OSPF Hello Packet
Network Mask: 0.0.0.0
Hello Interval: 10 seconds
Router Dead Interval: 40 seconds
Designated Router: 0.0.0.0
Backup Designated Router: 0.0.0.0
Active Neighbor: 192.168.30.5

Below is the router. we can verify what we saw above.

#ospf interface
ospfd4# sh ip o i
.
eth2 is up
  ifindex 4, MTU 1500 bytes, BW 0 Kbit <UP,BROADCAST,RUNNING,MULTICAST>
  Internet Address 192.168.30.4/31, Broadcast 192.168.30.255, Area 0.0.0.0
  MTU mismatch detection:enabled
  Router ID 192.168.30.5, Network Type POINTOPOINT, Cost: 10
  Transmit Delay is 1 sec, State Point-To-Point, Priority 1
  No designated router on this network
  No backup designated router on this network
  Multicast group memberships: OSPFAllRouters
  Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
    Hello due in 7.300s
  Neighbor Count is 1, Adjacent neighbor count is 1
.

And below ping test from router 1 to both 4 and 5 are working

/ # ping 192.168.30.4
PING 192.168.30.4 (192.168.30.4): 56 data bytes
64 bytes from 192.168.30.4: seq=0 ttl=64 time=12.415 ms
64 bytes from 192.168.30.4: seq=1 ttl=64 time=0.435 ms
^C
--- 192.168.30.4 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.435/6.425/12.415 ms
/ # ping 192.168.30.5
PING 192.168.30.5 (192.168.30.5): 56 data bytes
64 bytes from 192.168.30.5: seq=0 ttl=63 time=11.015 ms
64 bytes from 192.168.30.5: seq=1 ttl=63 time=0.730 ms
^C
--- 192.168.30.5 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.730/5.872/11.015 ms

So it is fully working. Let's go to questions.

Error

when I was trying to change the netmask to /31 I first used this command

ifconfig eth2 192.168.0.4/31

Look perfectly legal and innocent, but it does not work as expected. Instead of assign the proper IP address with subnet, it add the interface into /24.

The command which works in this case is

ifconfig eth2 192.168.30.4 netmask 255.255.255.254

So, the best way is always the old way.