Some hosting providers started offering IPs or IP aliases with /32 bit mask (for example Hetzner). Virtual interfaces such as
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 188.8.131.52 / 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 184.108.40.206 220.127.116.11 -static -iface -ifp em0
Then we can finally add a default route, simply specifing
route add default 18.104.22.168
Now we can put it all together and save it in
/etc/rc.conf. Static routes can be defined in
static_routes variable, and then expanded by name and executed in order of definitions:
ifconfig_em0="22.214.171.124/32" static_routes="em0_p2p em0_default" route_em0_p2p="126.96.36.199 188.8.131.52 -static -iface -ifp em0" route_em0_default="default 184.108.40.206"