Once OpenBSD was running on ESX Server, there was a configuration issue that had to be addressed involving static routes. This is probably one of those times where the OpenBSD experts are saying, “This is so simple!â€, but I had to search a bit to find the answer. So, for future reference and for the reference of those of us who are not OpenBSD experts (yet), here’s the solution.
There are actually two solutions. The first solution involves the use of the hostname.if file. OpenBSD maintains a separate hostname.if file for each interface, where the “.if†is replaced by the devicename. In a virtualized instance, this would typically be “le1†for the first NIC, “le2†for the second NIC, etc. Therefore, the first NIC would be configured using hostname.le1, and the second NIC would be configured using hostname.le2.
To add a static route to an interface, append a route command to the appropriate hostname.if file. Here’s an example:
inet 192.168.254.254 255.255.255.0 NONE !route add default 192.168.254.1
The key, of course, is the “!route add …†statement. This is the piece that I needed.
You can also add similar statements to /etc/rc.local, which will do the same thing. Note, however, that these statements cannot go into /etc/rc.conf.local.
Tags: BSD, Networking


2 comments
Tuesday, April 4, 2006 at 9:38 pm
Natalia Gorbski
The interfaces start with 0, like lo0 for local loop back. The default route goes in /etc/mygate, just like the computer’s name goes in /etc/myname. The routing statement of route add 209.162.120.8/29 24.240.30.1 works just fine in /etc/rc.conf.local.
Friday, April 7, 2006 at 6:33 pm
slowe
When running OpenBSD 3.8 under VMware (GSX Server or ESX Server), the first network adapater is le1, not le0 as would be expected. That is, unless you allow OpenBSD to use the new pcn driver (which I could never get to work) in which case it will start as pcn0.
The interesting thing, Natalia, is that I did have a default route in /etc/mygate, but it still didn’t work. I had edited dhclient.conf to instruct the external interface not to accept the default gateway parameter via DHCP and then added the default route in /etc/mygate, but it still didn’t work. The only way to make it work was to add the static routes as described above, or in /etc/rc.local.
I did try using /etc/rc.conf.local, but it didn’t work–it tried to add the routes before the interfaces were fully initialized. I’m not sure why it works for you, but it didn’t work for me at all.