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.


You use eth:N notation for that.

auto eth0
iface eth0 inet dhcp

auto eth0:0
iface eth0:0 inet static
  • Errrr, could you say a bit more than that? I see nothing about that in the man page. – Paul Hoffman Feb 6 '11 at 4:30
  • Do you see "eth0" section in config? You can add "eth0:1" section as well. – poige Feb 6 '11 at 4:38
  • += And even "eth0:0", since it's numbered from zero. – poige Feb 6 '11 at 4:50
  • I added an example that demonstrates what poige mentioned. Though I have never actually used this myself. – Zoredache Feb 6 '11 at 5:03
  • @Zoredache, you've left no chances of discovery to Paul. :-) – poige Feb 6 '11 at 5:21

ip can add multiple addresses to an interface.

iface eth0 inet dhcp
    up ip addr add dev eth0
  • The question was about adding multiple methods, not just multiple addresses. – Paul Hoffman Feb 6 '11 at 16:20
  • @Paul: I just tried, and it does add DHCP + static to eth0. – grawity Feb 6 '11 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.