0

I have a Linux machine with one Ethernet interface eth0 which already has one primary static address and one secondary static address (eth0:1) assigned. I would like to use DHCP to dynamically assign a third address to eth0:2. This is an old question and the canonical answer is, no, you can't do that; dhclient and dhcpcd don't work on alias interfaces. See this related question "How to request dhcp (using dhclient) on a virtual interface (i.e. eth0:1)" for which kce's answer gives a good explanation of the fundamental impossibility. (There's also mention there of a potential solution involving a VLAN, but this isn't an option for me.)

Now, AFAIK, the DHCP protocol doesn't care about interfaces (alias or otherwise); its job is simply to lease IP addresses to clients. So I'm thinking of trying to rig up a configuration involving dhclient or dhcpcd where they use eth0 for the packet-level communications with the local DHCP server, but then, once an address is obtained, use that address to configure eth0:2. Has anyone ever done this? Should it be possible? Are there pitfalls or other impossibilities I'm overlooking? (I'm prepared to modify the dhclient or dhcpcd source if I need to, if there aren't fundamental impossibilities. I'm also prepared to use a custom dhclient-script to set up eth0:2 and its routing correctly, once I have an address.)

3
  • What on earth is going on with your network, then? Commented Oct 26, 2015 at 15:01
  • The machine is normally on a teeny-tiny isolated network with a handful of other machines and with nothing but hand-assigned 10.* and 192.168.* addresses. But occasionally it would be useful to connect it to a larger network, and only then might DHCP come into play. Commented Oct 26, 2015 at 15:12
  • Beginning to answer my own question: It looks like lightly modifying dbclient-script to configure a specific interface -- not necessarily the primary one that dhclient used for lease negotiation -- will suffice to solve my problem. (Now I just need to, like, actually test it.) Commented Oct 26, 2015 at 16:21

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.