OSPFv2 Component
Enabling the OSPFv2 Component
The OSPFv2 configuration is held under the top level ospfv2 object in /etc/flockd/flockd.json. If the ospfv2 object exists OSPFv2 will be enabled and the OSPFv2 master thread will be started.
The Flock Networks Routing Suite is designed for massive scale so placing all routers in a single OSPF area is recommended. (If you are adding a device to an existing multi-area OSPF Autonomous System, multiple areas are fully supported).
With this configuration file:
-
The OSPFv2 master thread will be started
-
The OSPFv2 router will advertise a router id of
10.0.100.2 -
All interfaces with names starting with
enwill be placed in OSPF area 0."ospfv2": { "vrfs": { "default": { "router_id": "10.0.100.2", "areas": { "0.0.0.0": { "intfs": { "^en": {} } } } } } }
This is all the OSPFv2 configuration you need, to create an OSPF network as large as you like. Each device has an identical configuration which simplifies the operation of the network. A management station can easily determine all the Router Id's in the network by querying a single device for all of its Router LSA's.
Redistribution of routes into OSPF
You may wish to redistribute routes from the RIB into OSPFv2. Use the redistribute json object. The origin field specifies the protocol that programmed the routes into the RIB.
flock@flocknet:~$ cat /etc/flockd/flockd.json
...
"ospfv2": {
"vrfs": {
"default": {
"redistribute": [
{
"metric": 200,
"metric_type": 2,
"origin": "static"
}
]
}
}
}
As a minimum we may want a default route added to the kernel of each ASBR router. This route will appear in the RIB and then be redistributed into OSPFv2. OSPFv2 will advertise this route across the AS, so all nodes learn the route to exit the network. Static routes are added using the flockd static component.
flock@flocknet:~$ cat /etc/flockd/flockd.json
...
"static": {
"vrfs": {
"default": {
"routes": {
"0.0.0.0/0": {
"next_hops": [
{
"ip_addr": "192.168.122.171",
"intf_name": "enp8s0"
}
]
}
}
}
}
}
Stub Router
Configure the router to advertise maximum metric in its Router LSA, causing other routers to avoid using it as a transit node. This is useful during maintenance windows or router startup.
"ospfv2": {
"vrfs": {
"default": {
"stub_router": {
"mode": "MaxMetric",
"always": true
}
}
}
}
Default Route Origination
Advertise a default route into the OSPF domain.
"ospfv2": {
"vrfs": {
"default": {
"default_originate": {
"always": true
}
}
}
}
When always is true, the default route is originated regardless of whether one exists in the RIB.
Administrative Distance
Override the default OSPF administrative distance (default: 110).
"ospfv2": {
"vrfs": {
"default": {
"admin_distance": 115
}
}
}
LSA Arrival Timer
The timer_lsa_arrival sets the minimum interval (in milliseconds) between accepting the same LSA from a neighbor.
"ospfv2": {
"vrfs": {
"default": {
"timer_lsa_arrival": 1000
}
}
}
Area Summary Ranges
Area summary ranges allow aggregation of prefixes at area boundaries.
"ospfv2": {
"vrfs": {
"default": {
"areas": {
"0.0.0.1": {
"summary": {
"10.0.0.0/8": {
"advertise": true
}
},
"intfs": {
"^eth": {}
}
}
}
}
}
}
Implicit Router Id
With no explicit configuration the highest IPv4 Address is used as the Router Id. IPv4 Addresses on loopback interfaces are always preferred over IPv4 Addresses on physical interfaces.
Explicit Router Id
To explicitly set the Router Id to 10.0.100.1.
flock@flocknet:~$ cat /etc/flockd/flockd.json
...
"ospfv2": {
"vrfs": {
"default": {
"router_id": "10.0.100.1",
...
}
}
}
Advertising the IPv4 Address that is being used as the Router Id
When operating a network it can be useful to have the Router Id's advertised as an IPv4 host route in OSPF. This means the Router Id will respond to network operation tools such as ping and traceroute. To do this create a loopback interface and assign the IPv4 host route to it. Then enable OSPF on the interface that is providing the Router Id IPv4 address.
Create a loopback interface and assign the IPv4 host route to it.
The method for permanently adding IP addresses to loopback interfaces is Linux distribution specific. For example Debian uses the /etc/network/interfaces file.
flock@flocknet:~$ cat /etc/network/interfaces
...
# The loopback network interface
auto lo
iface lo inet loopback
# Add IPv4 Address to be used as RouterId
auto lo:20
iface lo:20 inet static
address 70.0.100.71/32
...
flock@flocknet:~$ sudo systemctl restart networking
flock@flocknet:~$
Enable OSPF on the loopback interface
flock@flocknet:~$ cat /etc/flockd/flockd.json
...
"ospfv2": {
"vrfs": {
"default": {
"areas": {
"0.0.0.0": {
"intfs": {
"lo": {}
}
}
}
}
}
},
Check the Router Id is as expected
flock@r71:~$ flockc -f json-pretty ospfv2 inst default ospfv2 show
...
"id": "70.0.100.71",
...
Operational State Overview
Check OSPFv2 is enabled
Check OSPFv2 is listed in the enabled_protocols field.
flock@r70:~$ flockc sys overview
{"host_info":{"hostname":"r70", ...},"system_info":{"name":"flockd", ...},"pid":1234,"log_level":"info","uptime":"days: 0, hours: 0, mins: 0, secs: 19","enabled_protocols":["OSPFv2"],"software_errors":0, ...}
Show OSPFv2 Overview
flock@r70:~$ flockc ospfv2 inst default ospfv2 show
[{"my_router":{"id":"70.0.100.70","class":""},"vrf_name":"default", ...,"stats":{"ls_db_counters":{...},"route_count":8,"neigh_state_count":{"down":0,"attempt":0,"init":0,"two_way":0,"ex_start":0,"exchange":0,"loading":0,"full":3}}}]
Show all neighbors on an interface in Area 0
flock@r70:~$ flockc ospfv2 inst default ospfv2 area 0 intf enp1s0 neighbors
[{"ip_addr":"70.0.75.71","router_id":"70.0.100.71", ...,"state":"Full","dr":...,"bdr":..., ...}]
Show Area 0 Link State Database
flock@r70:~$ flockc ospfv2 inst default ospfv2 area 0 lsdb
[{"V2":{"hdr":{"lsa_age":56,"lsa_opts":"E","lsa_type":"Router","lsa_id":"70.0.100.70","lsa_router_id":"70.0.100.70","lsa_seq":-2147483645,"lsa_checksum":14522,"lsa_len":60},"body":{"Router":{...}}}}, ...]
Annotated OSPFv2 Configuration
"ospfv2": {
"vrfs": {
"<vrf-name>": {
# RFC2328 1.2 Router ID
# Optional: If not specified highest IPv4 Address is used.
"router_id": "String in dotted decimal format",
# Array of 'redistribute' objects
"redistribute": [
{
# Origin of the Routes in the RIB to be redistributed
"origin": ["static" | "connected"],
# RFC2328 2.3 Type 1 / Type 2 external metrics
"metric_type": [ 1 | 2 ],
# OSPF metric to reach redistributed routes, from this router.
# RFC2328 B. LSInfinity => 16777215
"metric": ( 0..16777215 )
},
],
# OSPFv2 Area level configuration
# -------------------------------
"areas": {
# RFC2328 C.2 Area ID (dotted decimal)
"<area-id>": {
# OSPFv2 Interface level configuration
# ------------------------------------
"intfs": {
# Key is the interface name
# Specify the entire interface name i.e. "eno1"
# or use ^ to match the start of interface names
# e.g. "^en" will match all interfaces that start with "en"
"<interface-name>": {
# OSPF interface type
# Optional: Default is "broadcast"
"ospf_intf_type": ["broadcast" | "point-to-point" | "nbma" | "point-to-multipoint"],
# RFC2328 C.3 Interface output cost
# Optional: Default is 10
"cost": ( 1..65,535 ),
# RFC2328 C.3 Router Priority
# Optional: Default is 1
"priority": ( 0..255 ),
# RFC2328 C.3 HelloInterval
# Optional: Default is 10s
"hello_interval": ( 1..65,535 seconds),
# RFC2328 C.3 RouterDeadInterval
# Optional: Default is 40s
"dead_interval": ( 1..65,535 seconds),
# Retransmit interval in seconds
"rxmt_interval": <seconds>,
# Ignore MTU mismatch with neighbor
# Optional: Default is false
"mtu_ignore": [ true | false ],
# MD5 authentication
"auth": {
"auth_algo": "md5",
"auth_key_id": ( 0..255 ),
"auth_key": "<key-string>"
},
# BFD failure detection
"bfd": {
"multiplier": ( 1..255 ),
"min_tx": "<duration>"
}
}
}
}
}
}
}
}
Example Exhaustive OSPFv2 Configuration
"ospfv2": {
"vrfs": {
"default": {
"router_id": "10.0.1.100",
"redistribute": [
{
"metric": 100,
"metric_type": 1,
"origin": "static"
},
{
"metric": 1000,
"metric_type": 2,
"origin": "connected"
}
],
"areas": {
"0.0.0.0": {
"intfs": {
"enp0s0": {
"cost": 20,
"dead_interval": 4,
"hello_interval": 1,
"priority": 10
},
"^eth": {
"cost": 40,
"dead_interval": 8,
"hello_interval": 2,
"priority": 20
}
}
},
"0.0.0.1": {
"intfs": {
"enp1s0": {
"cost": 30,
"dead_interval": 80,
"hello_interval": 20,
"priority": 30
}
}
}
}
}
}
}
OSPFv2 Operation
Help
flockc ospfv2 -h
List OSPFv2 instances
flockc ospfv2 instances
Overview of an instance (default VRF, default instance name ospfv2)
flockc ospfv2 inst default ospfv2 show
List areas
flockc ospfv2 inst default ospfv2 areas
Area overview
flockc ospfv2 inst default ospfv2 area <area-id> show
All interfaces in Area 20
flockc ospfv2 inst default ospfv2 area 20 interfaces
Interface overview
flockc ospfv2 inst default ospfv2 area <area-id> intf <intf-name> show
All neighbors on interface enp1s0 in Area 0
flockc ospfv2 inst default ospfv2 area 0 intf enp1s0 neighbors
Specific neighbor detail
flockc ospfv2 inst default ospfv2 area <area-id> intf <intf-name> neigh <ip-addr> show
Autonomous System Link State Database
flockc ospfv2 inst default ospfv2 lsdb
Area 0.0.0.0 Link State Database
flockc ospfv2 inst default ospfv2 area 0 lsdb
LSDB filtered by LSA type
flockc ospfv2 inst default ospfv2 area <area-id> lsdb --lsa-type <type>
LSDB filtered by originating router ID
flockc ospfv2 inst default ospfv2 area <area-id> lsdb --router-id <router-id>
Network route table lookup / walk
flockc ospfv2 inst default ospfv2 rib lookup <ipv4-network>
flockc ospfv2 inst default ospfv2 rib walk <root>
Router route table lookup / walk
flockc ospfv2 inst default ospfv2 router-rib lookup <router-id>
flockc ospfv2 inst default ospfv2 router-rib walk
Redistributed RIB
flockc ospfv2 inst default ospfv2 redist-rib walk
Event buffer
flockc ospfv2 event-log