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.

This seems to work fine:

dhclient eth0
ifconfig eth0:1 192.168.1.105 up

But not this:

ifconfig eth0 192.168.1.105 up
dhclient eth0:1

Is there any way to get dhcp on a virtual address?

share|improve this question
add comment

1 Answer

up vote 13 down vote accepted

You can't really do this. Your card only has one MAC address but multiple IP interfaces. They will need to have their addresses statically assigned.

When the DHCP server sends back the DHCPOFFER how does it get delivered to eth0:1 and not to eth0? eth0:1 sends out a DHCPDISCOVER or a DHCPREQUEST by broadcasting. The DHCP server responds with a DHCPOFFER to inform the client of its IP address. But how will the DHCPOFFER arrive if eth0:1 doesn't yet have an IP address? The DHCP server broadcasts back and relies on the link layer to correctly deliver the ethernet frame (with the other associated layers stacked on top of it) to the right MAC address. And now your device has an IP address.

The problem for the DHCPOFFER is that from a Layer-2 perspective the two "devices" (eth0 and eth0:1) are indistinguishable, and so (from a Layer-3 perspective) the DHCPOFFER is destined for 255.255.255.255 (because eth0:1 doesn't yet have an IP address).

You can get around this by using VLANs. VLANs will allow you to take the same physical broadcast domain and treat it like multiple "virtual" broadcast domains (hence the name).

share|improve this answer
    
Great answer! I think I saw similar answers on forums, but this one is much clearer and I get it now. It appears that if I were to follow these instructions cyberciti.biz/tips/… I would then be able to do dhclient eth0.1 to get a DHCPOFFER. –  CoolAJ86 Sep 7 '11 at 16:05
    
Yep. As long as your networking infrastructure is setup correctly for VLANs. See How Do Vlans Work?. –  kce Sep 7 '11 at 17:25
add comment

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.