Dynamic Routing (FRR)

Dynamic Routing (using routing protocols) is supported via an external plugin. Routing protocols support your network equipment in finding the best available path for your packets. We use Free Range Routing (FRR) to implement the various available protocols for dynamic routing.

These routing protocols are used to:

  • Improve fault tolerance (if a connection breaks, a new route will be found if possible)

  • Simplify administration (you have to add fewer routes manually)

It is not adviseable to use dynamic routing in the following scenarios:

  • When your network is small (it would be simpler to use static routes)

  • If you are working in a highly isolated environment, where you have to be in control of every route in your network

Routing Protocols supported by the plugin include:

  • RIPv1 and RIPv2

  • OSPFv2 and v3

  • BGPv4

Warning

Not all routing protocols will work in any setup because they may have to be direct neighbors. Consider the limitations of a routing protocol before using it.

Warning

It’s strongly advised to increase the kern.ipc.maxsockbuf value via Tunables. Go to System ‣ Settings ‣ Tunables and check if there is already a tunable for maxsockbuf and set it to 16777216 if it is lower. Otherwise add a new one with name above and the specified value.

Warning

Disabling a running routing daemon can be dangerous as it can lead to an inaccessible machine. If you want to disable a running routing daemon, make sure you do not lose routes which are required by your connection to this machine (for example when using SSH).

Installation

Go to System ‣ Firmware ‣ Plugins and select os-frr from the available plugins.

General setup

To use one or more of the protocols included, the plugin must be enabled in Routing ‣ General. Without any other service enabled this makes sure the zebra service is being configured, which is the coordinating master service which handles generic features such as logging and acccess to kernel routing.

Tip

By default logging should be enabled, which sends messages to the local logging and offers remote logging over syslog. Always make sure to choose a sensible log level (default is Notifications) and check the log in Routing ‣ Diagnostics -> Log

Note

Since OPNsense does not support a form of configuration reloading at the moment, there might be a temporary loss of service when saving settings. Normally this is only a small glitch, but in high traffic areas it might be something to take under consideration when performing maintenance.

Dynamic routing and high availability

In enterprise networks there is often a need to protect services against all sorts of failures. Dynamic routing helps to always provide a valid path for packets to travel. These nodes themselved might need to be configured more resilient to prevent single points of failures on the edges of your network.

In OPNsense high availability and failover is organised around carp, which makes it a logical choice to combine both technologies here as well.

There are different strategies ranging from disabling the daemon when in carp mode, to more fine grained control of route propagation when a machine is in backup mode.

Note

Unicast CARP is available to use the protocol across router boundaries. This can enable the use of CARP on WAN interfaces peering with eBGP neighbors if they are not connected to the same switch.

CARP failover mode

The most simple mode available. When a node becomes Backup it will stop the FRR services. When it returns to Master it will start the FRR services.

Note

Due to the nature of this option, it cannot be combined with other available CARP options.

OSPF[6]: CARP demote

This option registers a status monitor on top of the FRR logging feed to detect changes in link status. If OSPF cannot find its neighbors, it will make this machine less attractive by increasing the demotion factor.

The feature is inspired by OpenBSD’s handling of CARP demotion in ospfd (https://man.openbsd.org/ospfd.conf.5) and can be enabled using the CARP demote checkbox in Routing: OSPF[v3].

Note

Since the relevant neighbor negotiation messages are only being logged when the log level (in Routing ‣ General) is configured to debug, the log will be more chatty when using this feature. When using a lower log level the status monitor is not expected to catch any relevant events.

OSPF[6]: Influence interface cost based on CARP status

FRR does not natively support interaction with CARP status as the variant in OpenBSD does (carp note in “depend on” keyword https://man.openbsd.org/ospfd.conf.5), this is where our next option comes into play.

Using the interface settings of an OSPF interface you can choose to adjust costs for that interface based on the CARP status of the selected virtual address. Go to Routing ‣ OSPF[v3] -> Interface and choose an interface, here you will find the following options that influence behaviour:

  • Depend on (carp):

    • Select a virtual address that this interface relies on. When this target is not in MASTER mode, the selected interface is considered demoted

  • Cost (when demoted):

    • Adjust the cost to this value when going to demoted state, usually one would use a high value here to prefer other routes first

  • Cost:

    • The standard cost, when provided will be used when in normal conditions. If it’s left blank FRR defaults will be used, which it will also rollback to when going back to master mode.

Dynamic Routing Protocols

For more detailed information, check out the FRR documentation.

Routing ‣ General

Options

Description

Enable

This will activate the routing service. Without enabling it globally, none of the individual services will run.

Profile

Control FRR’s default profile: traditional reflects defaults adhering mostly to IETF standards or common practices in wide-area internet routing. datacenter reflects a single administrative domain with intradomain links using aggressive timers.

Enable CARP Failover

This will activate the routing service only on the master device. The backup device will stop the service completely.

Enable SNMP AgentX Support

This will activate support for Net-SNMP AgentX.

Enable logging

Sends logs to the OPNsense integrated syslog-ng service.

Log Level

This is the detail level of the log. A higher level means more data is logged.

Firewall Rules

Enable automatically created firewall rules, when additional policies are needed, disable this and define your own custom policies in the Firewall section.

Attention

Any route received with dynamic routing protocols will only be installed if no similiar local route already exists. E.g., if a neighbor advertises a default gateway route, but a directly attached default gateway route already exists, the local route will be preferred and the advertised route will be discarded.

RIP (Routing Information Protocol) - legacy

Routing ‣ RIP

Options

Description

enable

This will activate the RIP service.

Version

Choose your RIP version (1 or 2). 1 is classful, 2 supports CIDR.

Passive Interfaces

Select the interfaces, where no RIP packets should be sent to, (e.g., WAN interface).

Route Redistribution

Select other routing sources, which should be redistributed to the other nodes. A good choice is Connected Routes to automatically redistribute all locally attached routes to other routers with RIP. Otherwise use the Networks option to manually insert networks to distribute.

Networks

Enter your networks in CIDR notation like 127.0.0.0/8.

Default Metric

Set the default metric to a value between 1 and 16. Routes with lower metrics will be preferred, while higher metrics indicate less preferred or distant paths.

The Routing Information Protocol (RIP) is a basic distance-vector routing protocol that determines the best path to a network destination based on hop count. With a maximum limit of 15 hops, RIP is suitable only for smaller networks. To prevent routing loops, RIP employs techniques like split horizon, route poisoning, and holddown timers. While easy to configure, RIP has slow convergence and limited scalability, making it less popular in modern networks compared to more efficient protocols like OSPF. It should be considered a legacy protocol.

OSPF/OSPFv3 (Open Shortest Path First)

Routing ‣ OSPF Routing ‣ OSPFv3

Options

Description

Enable

This will activate the OSPF service.

CARP demote

Register CARP status monitor. When no neighbors are found, consider this node less attractive. Requires syslog enabled with “Debugging” logging. Incompatible with “Enable CARP Failover”.

Router ID

(OSPF) If you have a CARP setup, you may want to configure a router id in case of a conflict. (OSPFv3) Router ID as an IPv4 Address to uniquely identify the router.

Reference Cost

(OSPF only) Adjust the reference cost in Mbps for path calculation, useful when bundling interfaces for higher bandwidth.

Passive Interfaces

Select the interfaces where no OSPF packets should be sent.

Route Redistribution

Select other routing sources to redistribute to other nodes.

Redistribution Map

Route Map to set for Redistribution, can be used to send a specific network as advertisement when it is defined in a Prefix List attached to a Route Map.

Log Adjacency Changes

If it should be logged when the topology of the area changes.

Advertise Default Gateway

This will send the information that we have a default gateway.

Always Advertise Default Gateway

Always sends default gateway information, regardless of availability.

Advertise Default Gateway Metric

Allows manipulation of the metric when advertising the default gateway.

Open Shortest Path First (OSPF) is a widely used link-state routing protocol designed for IP networks within a single autonomous system (AS). Operating as an interior gateway protocol (IGP), OSPF builds a network topology map by gathering link-state information from routers, allowing it to create an optimal routing table for IP packet delivery. OSPFv2 (RFC 2328) supports IPv4, while v3 (RFC 5340) extends support to IPv6.

BGP (Border Gateway Protocol)

Routing ‣ BGP

Options

Description

Enable

This will activate the BGP service.

BGP AS Number

Your AS Number here.

BGP AD Distance

Adjust BGP administrative distance, typically set to 20. Useful if you want to prefer OSPF-learned routes.

Router ID

Optional fixed router ID for BGP.

Graceful Restart

Enable BGP graceful restart as per RFC 4724, allowing packet forwarding during protocol restoration.

Network

Defines connected networks to be advertised over BGP. Disable Network Import-Check to announce all networks.

Network Import-Check

By default, only networks present in the routing table are advertised. Disable to announce all configured networks.

Log Neighbor Changes

Enable extended logging of BGP neighbor changes.

Route Redistribution

Select routing sources to redistribute to other nodes.

Border Gateway Protocol (BGP) is an exterior gateway protocol used to exchange routing information between autonomous systems (AS) on the Internet. As a path-vector protocol, BGP makes routing decisions based on defined paths, network policies, or administrator-configured rules. BGP has two main types: iBGP, used for routing within a single AS (using private AS numbers from 64512 to 65534), and eBGP, which operates between different AS across the Internet (using public AS numbers 1 to 64511). BGP’s flexibility and scalability make it essential for global Internet routing and large network infrastructures.

Supplemental Protocols

BFD (Bidirectional Forward Detection)

Routing ‣ BFD

Options

Description

Enable

This will activate the BFD service.

Bidirectional Forwarding Detection (BFD) is a lightweight protocol used to detect faults between routers or switches by sending periodic Hello packets (asynchronous mode). BFD quickly identifies failing links, making it a useful companion to routing protocols like OSPF and BGP for faster convergence.

STATIC (Static Routes Daemon)

Routing ‣ STATIC

Options

Description

Enable

This will activate the staticd service

STATIC is a daemon that handles the installation and deletion of static routes. These routes can be used supplemental to dynamic routes. It is beneficial for fine grained control over routes in more complex network environments, if redistributing directly attached routes is not an option.