dynamic host control playtime

Wednesday, 08 August 2007

dynamic host control playtime

During the past couple months of Internet service switching I was hoping to get some type of service that would allow me one or more static IP's. But in the end I found myself back on cable again, with nothing but DHCP. Static addresses wishes dashed, I then wondered if it was possible to get multiple IP's, even if they were randomly assigned.

Basically I wanted to see if it was possible to get multiple DHCP-allocated addresses on a single machine and from the same physical network/DHCP servers. This may sound unusual, impossible or pointless, but I had some uses in mind... and since my router is a PC running Linux rather than some proprietary device, I figured there was probably a way to do it. One of the appeals was the idea that I could have traffic from my public (open wireless) originate from a different public IP than my private local networks. So I set about playing with DHCP to see what I could do.

The obvious and simple solution might be adding another NIC to my router and connecting it to my cable modem, but that won't work because the cable modem will only communicate with a single NIC/MAC address. Since I can only have one NIC, I would have to somehow run multiple DHCP clients on the same WAN interface. I don't know of any DHCP capable device or OS that actually supports such silliness, but if you can completely control the DHCP client, it seems this is possible. Fortunately I'm running Linux, and I've got root.

It wasn't immediately apparent how to make this work with dhclient, so I started out playing with dhcpcd. Using interface aliases (eg. eth0:0) it wasn't long before I was able to get a few different addresses. However I quickly got frustrated with dhcpcd. It seems to be configured almost entirely with command line arguments and I had difficulty finding documentation on these options and getting it to behave as I wanted. I turned back to dhclient and discovered that I could easily run multiple instances of dhclient on the same interface by specifying a different config*, pid and lease file for each one. By using some custom dhclient-scripts** I was able to get dhclient to request and properly handle seemingly as many public IP's as I desired.

* The only config option needed was a unique dhcp-client-identifier for each dhclient instance. I used a random string for each.

** I modified the stock dhclient-script to assign the allocated IP to an interface alias I defined with an environment variable and I customized the routing commands so they wouldn't create competing default routes.

Trackbacks

    No Trackbacks

Comments

Display comments as (Linear | Threaded)

    No comments


Add Comment


Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5