This article follows on from getting the simplest example of OSPF working. It gives the frr commands to display useful information.
How to extract useful information
This article is a good introduction in drawing the network based on the information from OSPF.
Filter the output
With the frr show commands you can use regular expressions to filter the output data.
show ip ospf database route | include address|router
gives
laptop# show ip ospf database route | include address|router LS Type: router-LSA (Link ID) Designated Router address: 10.1.0.3 (Link Data) Router Interface address: 10.1.0.2 LS Type: router-LSA (Link ID) Designated Router address: 10.1.0.3 (Link Data) Router Interface address: 10.1.0.3 ...
You can also issue the sudo vtysh -c “show ip database route” | …. and use standard Linux facilities like grep, less and sort.
Use JSON
You can display the output in JSON format, for example
show ip ospf route json
gives
Server# show ip ospf route json { "10.1.0.0/24": { "routeType": "N", "cost": 100, "area": "0.0.0.0", "nexthops": [ { "ip": " ", "directly attached to": "eno1" } ] }... }
With JSON you can find out the field names for example “cost” has a value 100.
Options and flags
Many commands give options and flags, such as
Options: 0x2 : *|-|-|-|-|-|E|-
LS Flags: 0x6
I’ve collected some interpretation on these here.
I want to…
- Display a summary of the configuration, number of links, number of interfaces. show ip ospf
- Display the directly connected links. show ip ospf database router self-originate
- Display all links. show ip ospf database router
- Display links for a specific ospf router. show ip ospf database router 9.2.3.4
- Display the IP addresses in the network, show ip ospf route
- Display all of the routers in the network. show ip ospf database router| include Advertising Router
- Display the connection from an ospf router. show ip ospf database router 9.2.3.4 | include Designated Router address
- Display information about an interface on this machine. show ip ospf interface enp0s31f6
- Display traffic statistics about an interface. show ip ospf interface traffic
- Display the routes on this box. show ip route
frr commands
show ip ospf
OSPF Routing Process, Router ID: 1.2.3.4 ... Number of areas attached to this router: 1 Area ID: 0.0.0.0 (Backbone) Number of interfaces in this area: Total: 1, Active: 1 Number of fully adjacent neighbors in this area: 1 Area has no authentication SPF algorithm executed 4 times Number of LSA 5 Number of router LSA 3. Checksum Sum 0x000109da Number of network LSA 2. Checksum Sum 0x000139df Number of summary LSA 0. Checksum Sum 0x00000000 ...
There are 3 router Link States, and 2 network Link States; they are displayed below:
show ip ospf database
OSPF Router with ID (1.2.3.4) Router Link States (Area 0.0.0.0) Link ID ADV Router Age Seq# CkSum Link count 1.2.3.4 1.2.3.4 288 0x80000003 0x15a9 1 9.2.3.4 9.2.3.4 288 0x80000007 0x56f1 2 10.1.1.2 10.1.1.2 1078 0x8000001e 0x9d40 1 Net Link States (Area 0.0.0.0) Link ID ADV Router Age Seq# CkSum 10.1.0.3 9.2.3.4 289 0x80000001 0x7ba2 10.1.1.2 10.1.1.2 1082 0x80000003 0xbe3d
show ip ospf database router self-originate
This shows the links attached to this OSPF environment.
OSPF Router with ID (9.2.3.4) Router Link States (Area 0.0.0.0) Link State ID: 9.2.3.4 Number of Links: 2 Link connected to: Stub Network (Link ID) Net: 10.1.0.0 (Link Data) Network Mask: 255.255.255.0 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.1.2 (Link Data) Router Interface address: 10.1.1.1
show ip ospf database router
OSPF Router with ID (1.2.3.4) Router Link States (Area 0.0.0.0) =================================== LS age: 387 Options: 0x2 : *|-|-|-|-|-|E|- LS Flags: 0x3 Flags: 0x0 LS Type: router-LSA Link State ID: 1.2.3.4 Advertising Router: 1.2.3.4 ... Length: 36 Number of Links: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.0.3 (Link Data) Router Interface address: 10.1.0.2 ... =================================== LS Type: router-LSA Link State ID: 9.2.3.4 Advertising Router: 9.2.3.4 Number of Links: 2 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.0.3 (Link Data) Router Interface address: 10.1.0.3 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.1.2 (Link Data) Router Interface address: 10.1.1.1 =================================== LS Type: router-LSA Link State ID: 10.1.1.2 Advertising Router: 10.1.1.2 Number of Links: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.1.2 (Link Data) Router Interface address: 10.1.1.2
show ip ospf database router 9.2.3.4
laptop# show ip ospf database router 9.2.3.4 OSPF Router with ID (1.2.3.4) Router Link States (Area 0.0.0.0) LS Type: router-LSA Link State ID: 9.2.3.4 Advertising Router: 9.2.3.4 Number of Links: 2 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.0.3 (Link Data) Router Interface address: 10.1.0.3 Link connected to: a Transit Network (Link ID) Designated Router address: 10.1.1.1 (Link Data) Router Interface address: 10.1.1.1
show ip ospf database network
laptop# show ip ospf database network OSPF Router with ID (1.2.3.4) Net Link States (Area 0.0.0.0) ==== LS age: LS Type: network-LSA Link State ID: 10.1.0.3 (address of Designated Router) Advertising Router: 9.2.3.4 Network Mask: /24 Attached Router: 1.2.3.4 Attached Router: 9.2.3.4 ==== LS age:... LS Type: network-LSA Link State ID: 10.1.1.2 (address of Designated Router) Advertising Router: 10.1.1.2 Network Mask: /24 Attached Router: 10.1.1.2 Attached Router: 9.2.3.4
show ip ospf route
Server# show ip ospf route ============ OSPF network routing table ============ N 10.1.0.0/24 [100] area: 0.0.0.0 directly attached to eno1 N 10.1.1.0/24 [10000] area: 0.0.0.0 directly attached to tap0 N 10.1.3.0/24 [10000] area: 0.0.0.0 directly attached to tap2 N 11.1.0.2/32 [200] area: 0.0.0.0 via 10.1.0.2, eno1
Where
- N is the route type,
- N, Network, Intra area
- N IA, network, Inter area
- D IA, Discard Inter area
- 10.1.0.0.24 is the IP address
- [] is the cost
- 0.0.0.0 is the area
show ip ospf interface enp0s31f6
This command shows the interface on the local system. I’ve displayed what I think is important. There are many more parameters, and it is missing the description from the configuration file!
enp0s31f6 is up ... ifindex 2, MTU 1500 bytes, BW 1000 Mbit <UP,BROADCAST,RUNNING,MULTICAST> Internet Address 10.1.0.2/24, Broadcast 10.1.0.255, Area 0.0.0.0 Router ID 1.2.3.4, Network Type BROADCAST, Cost: 100 Designated Router (ID) 9.2.3.4 Interface Address 10.1.0.3/24 Backup Designated Router (ID) 1.2.3.4, Interface Address 10.1.0.2 Neighbor Count is 1, Adjacent neighbor count is 1 ...
show ip ospf interface traffic
Interface HELLO DB-Desc LS-Req LS-Update LS-Ack Packets Rx/Tx Rx/Tx Rx/Tx Rx/Tx Rx/Tx Queued ---------------------------------------------------------- enp0s31f6 128/129 4/3 1/1 11/5 4/10 0
show ip ospf router-info
This just shows a setting – or Router Information is disabled on this router.
show ip route
The output below shows there is one OSPF defined route (which has been active for 1 hour 9:51 minutes). (There are other routes defined.)
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure K>* 0.0.0.0/0 [0/600] via 192.168.1.254, wlp4s0, 01:10:41 O 10.1.0.0/24 [110/100] is directly connected, enp0s31f6, weight 1, 01:10:41 K * 10.1.0.0/24 [0/100] via 10.1.0.2, enp0s31f6, 01:10:41 C>* 10.1.0.0/24 is directly connected, enp0s31f6, 01:10:41 O 10.1.1.0/24 [110/10100] via 10.1.0.3, enp0s31f6, weight 1, 01:09:51 K>* 10.1.1.0/24 [0/0] via 10.1.0.3, enp0s31f6, 01:10:41 K>* 10.2.1.0/24 [0/0] is directly connected, enp0s31f6, 01:10:41 K>* 10.3.1.0/24 [0/0] via 10.1.0.3, enp0s31f6, 01:10:41 K>* 169.254.0.0/16 [0/1000] is directly connected, virbr0 linkdown, 01:10:41 C>* 192.168.1.0/24 is directly connected, wlp4s0, 01:10:41
show ip rpf
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure C> 10.1.0.0/24 is directly connected, enp0s31f6, 01:12:22 C> 192.168.1.0/24 is directly connected, wlp4s0, 01:12:22
Options and flags
You get information displayed like
Options: 0x2 : *|-|-|-|-|-|E|- LS Flags: 0x6
Where the options are: See Wikipedia.
- * reserved
- O – router’s willingness to receive and forward Opaque-LSAs
- DC – Handling of Demand Circuits
- EA” : “-“, describes the router’s willingness to receive and forward External Attributes LSAs
- N/P – if area is NSSA.
- MC – Multicast datagrams forwarded
- E – external link advertisements are not flooded into OSPF
- M/T – Multi-Topology (MT) Routing in OSPF
- T – router’s TOS capability
and flags are:
- SELF 0x01
- SELF_CHECKED 0x02
- RECEIVED 0x04
- APPROVED 0x08
- DISCARD 0x10
- LOCAL_XLT 0x20
- PREMATURE_AGE 0x40
- IN_MAXAGE 0x80
Other information
ip -4 route
colinpaice@colinpaice:~$ ip -4 route default via 192.168.1.254 dev wlp4s0 proto dhcp metric 600 10.1.0.0/24 dev enp0s31f6 proto kernel scope link src 10.1.0.2 metric 100 10.1.0.0/24 via 10.1.0.2 dev enp0s31f6 proto static metric 100 10.1.1.0/24 via 10.1.0.3 dev enp0s31f6 10.2.1.0/24 dev enp0s31f6 scope link 10.3.1.0/24 via 10.1.0.3 dev enp0s31f6 169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown 192.168.1.0/24 dev wlp4s0 proto kernel scope link src 192.168.1.222 metric 600 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
One thought on “OSPF on Linux with frr: the basic commands”