Routing protocol OSPF
OSPF topology table
The topology table on an OSPF router is a link-state database (LSDB) that lists information about all other routers in the network, and represents the network topology. All routers within an area have identical link-state databases, and the table can be viewed using the show ip ospf database command. The SPF algorithm uses the LSDB to produce the unique routing table for each router which contains the lowest cost route entries for known networks.
OSPF States
Operation | State | Description |
---|---|---|
Establish neighbor adjacencies |
1. Down state | Negotiate master / slave relationship and DBD packet sequence number. The master initiates the DBD packet exchange. |
2. Init state | Hello packets are received from the neighbor. They contain the sending router’s Router ID. Transition to Two-Way state. | |
3. Two-Way state | On Ethernet links, elect a DR, and a BDR. Transition to ExStart state. | |
Synchronize OSPF Databases |
4. ExStart state | Negotiate master / slave relationship and DBD packet sequence number. The master initiates the DBD packet exchange. |
5. Exchange state | Routers exchange DBD packets. If additional router information is required then transition to Loading; otherwise, transition to Full. | |
6. Loading state | LSRs and LSUs are used to gain additional route information. Routes are processed using the SPF algorithm. Transition to the Full state. | |
7. Full state | Routers have converged. |
OSPFv2 router configuration for IPv4 protocol
r1(config)# router ospf process-id !value between 1 - 65535, does not need to be unique on all routers r1(config-router)# router-id x.x.x.x !value in IPv4 format r1(config-router)# network network-address wildcard-mask area area-id r1(config-router)# network intf-ip-address 0.0.0.0 area area-id !enabling advertisements via a quad 0 wildcard mask, !tells the router to enable interface Serial0/0/0 for the routing process r1(config-router)# passive-interface intf r1(config-router)# passive-interface default r1(config-router)# auto-cost reference-bandwidth 100 !note bandwidth value here is Mb/s r1(config-router)# ip ospf cost value !sets cost of the link
OSPFv2 Troubleshooting
show ip protocols clear ip ospf process !This forces OSPF on R1 to transition to the Down and Init states. Required if router-id needs changing show ip ospf neighbor !State - The OSPF state of the interface. FULL state means that the router and its neighbor have identical OSPF LSDBs. !On multiaccess networks, such as Ethernet, two routers that are adjacent may have their states displayed as 2WAY. !The dash indicates that no DR or BDR is required because of the network type. show ip ospf !spf, backbone area, router-id show ip ospf interface brief show ip ospf interface serial 0/0/1 !cost, bandwidth show interface serial 0/0/1 | include BW !verify the current bandwidth of an interface
OSPFv3 router configuration for IPv6 protocol
If no extra description is used it says that the command has the same meaning both in OSPFv2 and OSPFv3
r1(config)# ipv6 unicast-routing r1(config)# ipv6 router ospf process-id !only locally significant as in OSPFv2 r1(config-rtr)# router-id x.x.x.x r1(config-rtr)# passive-interface intf r1(config-rtr)# passive-interface default r1(config-rtr)# auto-cost reference-bandwidth 100 !note bandwidth value here is Mb/s r1(config-rtr)# ip ospf cost value !sets cost of the link
Cisco routers use IPv6 link-local addresses FE80:: to exchange LSA packets. The link-local address is automatically generated when IPv6 global unicast address is assigned to the interface. Cisco routers create the link-local address using FE80::/10 prefix and the EUI-64 process. EUI-64 involves using the 48-bit Ethernet MAC address, inserting FFFE in the middle and flipping the seventh bit. For serial interfaces, Cisco uses the MAC address of an Ethernet interface. The link local address can be assigned manually:
r1(config-if)# ipv6 address fe80::1 link-local
OSPFv3 Troubleshooting
clear ipv6 ospf process show ipv6 protocols !process ID, router ID, interfaces enabled show ipv6 ospf interfaces brief show ipv6 ospf neighbor !FULL state means that the router and its neighbor have identical OSPF LSDBs. On multiaccess !networks such as Ethernet, two routers that are adjacent may have their states displayed as 2WAY. !The dash indicates that no DR or BDR is required because of the network type. show ipv6 ospf interface brief !process ID, interface area, cost, state show ipv6 ospf interface serial 0/0/1 !router ID, link cost, network type, hello and dead time timers,
Enable interface to start advertising its network
r1(config-if)# ipv6 ospf process-id area area-id
Adjusting the Interface Bandwidth
r1(config)# interface serial 0/0/1 r1(config-if)# bandwidth 64 r1(config-if)# end
Default reference bandwidth for 100Mb/s is 10^8 100.000.000 therefore Fast Ethernet 100Mbps link cost is 1. Cost is calculated using formula:
cost = reference bandwidth bps / interface bandwidth in bps
show interface serial 0/0/1 | include BW !verify the current bandwidth of an interface
Setting up router-id
Router-ID (RID) is 32 bit number noted in the same way as IPv4, election process is as below:
- set by router-id command
- the highest logical (loopback) IPv4 address configured on a router
- if no logical/loopback IPv4 address is set then the router uses the highest IP address configured on its active interfaces
Option 1 via router config
r1(config-router)# router-id x.x.x.x !value in IPv4 format
Option 2 via loopback interface
r1(config)# interface loopback 0 r1(config-if)# ip address 1.1.1.1 255.255.255.255 !creates a host route, a 32-bit host route does not get advertised as a route to other OSPF routers r1(config-if)# end
Option 3 it will be the highest IPv4 active interface address in up state.
Differences between OSPFv2 vs OSPFv3
OSPFv2 | OSPFv3 | |
---|---|---|
Advertises | IPv4 networks | IPv6 prefixes |
Source address | IPv4 source address | IPv6 link-local address |
Destination address | neighbor IPv4 unicast address 224.0.0.5 all-OSPF-routers multicast address 244.0.0.6 DR/BDR multicats address |
neighbor IPv6 link-local address FF02::5 all-OSPFv3-routers multicast address FF02::6 DR/BDR multicast address |
Advertise networks | network router command | ipv6 ospf process-id area area-id interface configuration command |
IP unicast routing | Enabled by default | ipv6 unicast-routing global configuration command |
Authentication | plaintext authentication or MD5 authentication | IPv6 authentication, IPSec authentication |