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 dhcp inet 1.1.1.11 255.255.255.0 NONE up # 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 1.1.1.11 255.255.255.0 NONE dhcp up # 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 "example.com"; supersede domain-name-servers 1.1.1.1; } alias { interface "vr2"; fixed-address 1.1.1.11; option subnet-mask 255.255.255.0; }
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.
Neat.
Thanks, you r AWESOME!!!
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.
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 🙂
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!
Like your post.. thanks…
It appears that the “alias” directive went away with OpenBSD 5.0. Sad.
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.