Malte Krupa

Howto Configure Static IPv4 On FreeBSD On Hetzner Cloud - 2022-03-22


One would think that it is quite easy to configure a static IPv4 address on a hetzner cloud server on FreeBSD, but that is not the case. It’s not hard either, but took me a couple of minutes to understand what the issue is.

The documentation contains a paragraph about this topic but only mentions DHCP for IPv4:

ifconfig_vtnet0_ipv6="inet6 <one IPv6 address from your subnet, e.g.  2001:db8:0:3df1::1>/64"

They did the same for NetBSD, so my guess was that this is an uncommon configuration.

This post assumes the following:


Without the static route, you’ll run into the following error message when trying to add the default gateway.

root@hetzner-cloud-test:~ # route add default
route: writing to routing socket: Network is unreachable
add net default: gateway fib 0: Network is unreachable


Usually it is enough to configure your /etc/rc.conf to something like:

ifconfig_vtnet0="inet netmask"

But, to get around the Network is unreachable error, we also need to create a static route like so:

route_vtnet0=" -iface vtnet0"

That’s it. Reboot and everything should work.

Alternatively, to make it work at runtime, run the following commands:

ifconfig vtnet0 inet netmask
route add -iface vtnet0
route add default

Privacy Policy | Imprint