OpenBSD, dynamic and static IP address on the same interface

Today I was faced with the following problem: I was trying to configure one of the Ethernet interfaces of an OpenBSD 4.5 box with both a dynamic address leased via DHCP, but also a static IP address. Initially, I tried this:

# cat /etc/hostname.vr2
inet NONE
# sh /etc/netstart vr2

The problem with this approach is that dhclient never gets daemonized because netstart gets it annoyed: dhclient notices that something else reconfigured the interface and commits suicide. So, then I thought about reversing the order of the first two lines:

# cat /etc/hostname.vr2
inet NONE
# sh /etc/netstart vr2

Now dhclient daemonizes but also removes all previously configured IP addresses, so the statically configured address configured via the first line is wiped by dhclient. Not very nice.

Turns out the solution lies in /etc/dhclient.conf:

# cat /etc/dhclient.conf
interface "vr2" {
        supersede domain-name "";
        supersede domain-name-servers;

alias {
        interface "vr2";
        option subnet-mask;

The alias stanza allows one to define an additional, aliased IP address for an interface. Which allows the machine to be always reachable on a fixed IP address.


7 thoughts on “OpenBSD, dynamic and static IP address on the same interface

  1. I’m really glad I’ve found this info. Nowadays bloggers publish only about gossips and web and this is actually frustrating. A good web site with exciting content, that is what I need. Thanks for keeping this web site, I will be visiting it. Do you do newsletters? Can’t find it.

  2. For a long time, my family would always have a puzzle out that everyone would work on over the few days that everyone would be together. That’s fallen out of favor lately for some reason. We still always go to a museum on Christmas afternoon, or sometimes the day before or after. That’s particularly low-cost for us, as my parents live near DC and the Smithsonian is free 🙂

  3. Hi Delton! Thanks for watching! I’m really glad you enjoyed it. After Effects will make a great addition to your tool box, and a lot of the coming topics for Design in Motion will translate across platforms. Stay tuned!

  4. I do trust all of the ideas you have presented for your post. They’re really convincing and can definitely work. Still, the posts are very quick for beginners. May you please lengthen them a little from subsequent time? Thank you for the post.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s