Static routing is a form of network routing that allows administrators to manually specify the path for network packets to take through a network. In OpenBSD, you can configure static routes using the route
command.
Here’s an example of how to add a static route in OpenBSD:
- Open a terminal window.
- Log in as root.
- Run the following command:
route add -net destination_network gateway
Where:
destination_network
is the network address and subnet mask of the destination network.gateway
is the IP address of the next-hop router.
For example, to add a route to the network 192.168.1.0/24 via the gateway 192.168.0.1, you would run the following command:
route add -net 192.168.1.0/24 192.168.0.1
After adding the route, you can verify that it was added successfully by running the following command:
route show
This will display a list of all of the routes currently in the system routing table.
Note that these routes are not persistent across reboots. To make the routes persistent across reboots, you’ll need to add the route add
command to a startup script, such as /etc/rc.local
.