Some hosting providers started offering IPs or IP aliases with /32 bit mask (for example Hetzner). Virtual interfaces such as gif or tun have built-in ability to act as peer to peer devices and ifconfig utility can use that ability to easily setup of these interfaces, but ethernet devices need some special treatment.

The obvious way of configuring it by setting


will not work because default gateway is not in rage of mask on the interface. However there is an easy way to make it work that nicely fit with rc.conf. The first thing is to setup the IP configuration for an interface

ifconfig em0 / 32

(change em0 to the correct name of your interface and obviously adjust the IP address).
Next we need to add host route to our default gateway, but because the address will not fit in the /32 bit mask we supply -ifp flag to route to indicate the interface that should be used:

route add -static -iface -ifp em0

Then we can finally add a default route, simply specifing

route add default

Now we can put it all together and save it in /etc/rc.conf. Static routes can be defined instatic_routes variable, and then expanded by name and executed in order of definitions:

static_routes="em0_p2p em0_default"
route_em0_p2p=" -static -iface -ifp em0"

Leave a comment