Ubuntu – How to configure an interface to have *both* a DHCP address and a static address in Ubuntu

interfacenetworkingUbuntu

In a lab setup, I want eth0 on a Ubuntu server box to get a DHCP address for talking to the outside world, and I also want to assign it a static 10.x.y.z address for talking to other boxes on the local network that have 10.x.y.z addresses. I want to do this by editing /etc/network/interfaces.

The man page for /etc/network/interfaces is modeled after "here's a bunch of examples, I hope you can figure out the actual rules on your own". I don't see a way to give one interface two addresses using two different methods (static and dhcp), and initial fumbling didn't produce useful results.

Best Answer

You use eth:N notation for that.

auto eth0
iface eth0 inet dhcp

auto eth0:0
iface eth0:0 inet static
        address 192.168.32.10
        netmask 255.255.255.0