I had the same issue as Mike and found it difficult to get OpenBSD to properly route the assigned IP address. Similar to OVH, dedicated servers on myLoc.de provide IP addresses with 255.255.255.255 netmask which need to be routed point-to-point inside the VM. I had already dealt with this in other guest OSs. In Debian 10 I would set up the external IP in the guest like this:
# nano /etc/network/interfaces
iface eth0 inet static
address 56.78.91.56/32 ## this is the additional external IP
pointopoint 99.78.91.101 ## this is the gateway for the additional IP (which in my case is also the main IP of the server)
gateway 99.78.91.101
... and in Ubuntu 18.04 using netplan
it the relevant part would look like this, which works using on-link
:
network:
version: 2
renderer: networkd
ethernets:
eth0: #Interface-Name
addresses:
- 56.78.91.56/32 ## additional external IP
routes:
- to: 0.0.0.0/0
via: 99.78.91.101 ## gateway for the additional IP
on-link: true
Configuring this with the ip
command using the onlink
option I would do the following:
ip addr add 56.78.91.56/32 dev eth0
ip route add default via 99.78.91.101 dev eth0 onlink
Somehow the way the route
command is documented in OpenBSD and FreeBSD did not make it very clear how I could do a similar thing on BSD and there were almost no examples to be found using a web search. Maybe for those more familiar with networking the answer is obvious. I finally got it to work just before I found Mike's more complete answer in a separate article he posted. Therefore I will update his answer here with the configuration that actually works on OpenBSD 6.6 (eth0 is just a placeholder for the actual interface name):
ifconfig eth0 -inet 56.78.91.56/32
route -v add -inet 99.78.91.101/32 -link -iface eth0
route -v add -inet default 99.78.91.101
These commands create a routing table with the relevant lines like this:
route -n show -inet
Routing tables - Internet:
Destination Gateway Flags Refs Use Mtu Prio Iface
default 99.78.91.101 UGS 5 52 - 8 eth0
99.78.91.101 cc:aa:d2:4f:08:8f UHLSh 1 30 - 8 eth0 # MAC address on the server
56.78.91.56 7a:33:f7:42:44:7e UHLl 0 26 - 1 eth0 # MAC address of the VM
56.78.91.56/32 56.78.91.56 UCn 0 0 - 4 eth0
To permanently save the OpenBSD 6.6 configuration in the /etc/hostname.eth0
file use the following. (Apparently the 2 second delay is needed for all commands to be executed.)
inet 56.78.91.56/32
!sleep 2
!route -v add -inet 99.78.91.101/32 -link -iface eth0
!route -v add -inet default 99.78.91.101
This works currently on a Proxmox 6 server with OpenBSD as the guest running in a KVM. The external IP address is attached to the virtual bridge on the server. I do not know if a lot of dedi server companies have their networking set up like this making it harder to configure, but I encountered this on Webtropia, Servdiscount (both connected to myLoc) and seen similar questions on Hetzner.