OpenBSD: Static Routing Configuration

www‮.‬lautturi.com
OpenBSD: Static Routing Configuration

To configure static routing on OpenBSD, you will need to follow these steps:

  1. Edit the /etc/sysctl.conf file and add the following line to enable IP forwarding:
net.inet.ip.forwarding=1
  1. Edit the /etc/mygate file and add the default gateway for the system. The syntax is:
gateway_ip_address

For example, to set the default gateway to 192.168.1.1, you would add the following line to the file:

192.168.1.1
  1. Edit the /etc/hostname.interface file for the interface that will be used for static routing. For example, if you are using the em0 interface, you would edit the /etc/hostname.em0 file. Add the following lines to the file:
inet static_ip_address netmask netmask_value
route add default gateway_ip_address

Replace static_ip_address with the static IP address that you want to assign to the interface, netmask_value with the netmask for the network, and gateway_ip_address with the default gateway for the network.

  1. Add any additional static routes that you want to configure by adding the following lines to the /etc/hostname.interface file:
route add -net destination_network gateway_ip_address

Replace destination_network with the network that you want to route to, and gateway_ip_address with the gateway that should be used for the route.

  1. Save the changes and restart the network interface to apply the changes:
sudo sh /etc/netstart interface

Replace interface with the name of the network interface (e.g., em0).

That's it! Your static routing configuration should now be in place.

Created Time:2017-10-30 10:17:54  Author:lautturi