Friday, June 5, 2015

Configuring OpenBSD 6.1 KVM for static route external to egress subnet

So, I provisioned a{nother} small OpenBSD KVM server online recently and was handed a /32 IP address (no extended subnet) and a default route that would have required a /5 (248.0.0.0) to correctly operate -- such great planning on the part of the hosting provider. Meh.  I'm no stranger to odd routing practices, so I realize (and hope) I'm not alone when I complain about interface-based routing tables jacking things up.

Here's how it's accomplished within OpenBSD for the curious blogosphere.  In
/etc/hostname.vio0 (or /etc/hostname.em0, or whatever your interface is):

inet your.ip.address 255.255.255.255
!route add -inet your.default.gateway -llinfo -link -static -iface vio0

And, then in /etc/mygate:
your.default.gateway

This will allow your virtual machine to communicate with the external world.  I hope this helps someone out there!