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 en will be placed in OSPF area 0.

      "ospfv2": {
          "router_id": "10.0.100.2",
          "area": [
              {
                  "area_id": "0.0.0.0",
                  "intf": [
                      {
                          "name": "^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": {
    "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": {
    "static_routes": [
        {
            "ip_net": "0.0.0.0/0",
            "next_hops": [
                {
                    "ip_addr": "192.168.122.171",
                    "intf_name": "enp8s0"
                }
            ]
        }
    ]
}

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": {
    "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": {
    "area": [
        {
            "area_id": "0.0.0.0",
            "intf": [
                {
                    "name": "lo"
                }
            ]
        }
    ]
},

Check the Router Id is as expected

flock@r71:~$ flockc ospfv2 -j | grep router_id
"router_id": "70.0.100.71",
flock@flocknet:~$

Operational State Overview

Check OSPFv2 is enabled

Check OSPFv2 is listed in the enabled_protocols field.

flock@flocknet$ flockc system
"hostname": "flocknet"
"software": "Flock Networks Routing Suite"
"version": "20.4.0"
"model": "Large"
"base_os": "Linux"
"pid": 2423
"compile_mode": "Release"
"log_level": "info"
"uptime": Uptime { days: 0, hours: 0, mins: 0, secs: 19 }
"enabled_protocols": ["OSPFv2"]
flock@flocknet:~$

Show OSPFv2 Overview

flock@r01:~$ flockc ospfv2
{"router_id":"10.0.100.4","class":"IR","redistribute":[],"neigh_state_count":{"down":0,"attempt":0,"init":0,"two_way":0,"ex_start":0,"exchange":0,"loading":0,"full":6}}
flock@r01:~$

Show all neighbors (out of all interfaces, in all areas)

flock@r01:~$ flockc ospfv2 -n
{"ospf_area_id":"0.0.0.0"}
{"ospf_intf":"enp1s0"}
{"id":"10.0.100.3","ip":"10.0.5.225","state":"Full","dr":"10.0.5.204","bdr":"10.0.5.225"}
{"ospf_area_id":"0.0.0.20"}
{"ospf_intf":"enp7s0"}
{"id":"10.20.100.20","ip":"10.20.20.189","state":"Full","dr":"10.20.20.189","bdr":"10.20.20.214"}
flock@r01:~$

Show Area 0 Link State Database

flock@flocknet:~$ flockc ospfv2 -a 0 -l
{"lsa_age":279,"lsa_opts":{"bits":2},"lsa_type":"Router","lsa_id":"10.0.100.4","lsa_router_id":"10.0.100.4","lsa_seq":-2147483646,"lsa_checksum":28411,"lsa_len":36}
{"lsa_age":266,"lsa_opts":{"bits":2},"lsa_type":"Router","lsa_id":"10.0.100.5","lsa_router_id":"10.0.100.5","lsa_seq":-2147483646,"lsa_checksum":22802,"lsa_len":36}
...
flock@flocknet:~$

Annotated OSPFv2 Configuration

"ospfv2": {
    # 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": ["kernel-static" | "kernel-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
    # -------------------------------
    [[area]] # Array of 'area' objects
    "area": [
        {
            # RFC2328 C.2 Area ID
            "area_id": "String in dotted decimal format",
            # OSPFv2 Interface level configuration
            # ------------------------------------
            "intf": [
                {
                # 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"
                "name": "Interface Name",
                # 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),
                }
            ]
        }
    ]
}

Example Exhaustive OSPFv2 Configuration

"ospfv2": {
    "router_id": "10.0.1.100",
    "redistribute": [
        {
            "metric": 100,
            "metric_type": 1,
            "origin": "kernel-static"
        },
        {
            "metric": 1000,
            "metric_type": 2,
            "origin": "kernel-connected"
        }
    ],
    "area": [
        {
            "area_id": "0.0.0.0",
            "intf": [
                {
                "name": "enp0s0",
                "cost": 20,
                "dead_interval": 4,
                "hello_interval": 1,
                "name": "enp7s0",
                "priority": 10
                },
                {
                "name": "^eth",
                "cost": 40,
                "dead_interval": 8,
                "hello_interval": 2,
                "name": "enp8s0",
                "priority": 20
                }
            ]
        },
        {
            "area_id": "0.0.0.1",
            "intf": [
                {
                "name": "enp1s0",
                "cost": 30,
                "dead_interval": 80,
                "hello_interval": 20,
                "name": "enp9s0",
                "priority": 30
                }
            ]
        }
    ]
}

OSPFv2 Operation

Help

flockc ospfv2 -h

Overview

flockc ospfv2

Overview of areas

flockc ospfv2 -a [<area-id>]

All interfaces in Area 20

flockc ospfv2 -i -a 20

All neighbors on interface enp1s0 in Area 0

flockc ospfv2 -n -i enp1s0 -a 0

All neighbors on all interfaces in all areas

flockc ospfv2 -n

Autonomous System Link State Database

flockc ospfv2 -l

Area 0.0.0.0 Link State Database

flockc ospfv2 -a 0 -l

Network route table prefixes

flockc ospfv2 -p [<ipv4-network>]

Router route table prefixes

flockc ospfv2 -P [<router-id>]