Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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
share|improve this answer
    
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 192.168.32.10/24 dev eth0
share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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