Multi-homed, multi-DHCP client (GNU/Linux)

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 371
Joined: Tue Nov 12, 2013 2:05 am

Multi-homed, multi-DHCP client (GNU/Linux)

Post by peter_b »

I've had the problem that when I have a machine connected to more than 1 physical network, where each one has its own DHCP, there are problems:
It would be great to have the name-resolution (/etc/resolv.conf) settings combined, by merging the information gathered from each network - but by default, one DHCP-client just overwrites the other network's settings.

Here's a quick HowTo what worked for me on Debian Squeeze (6.0.2):

1) Setup your network interfaces as usual:
Let's assume we have "eth0" and "eth1" for each network. Both networks have their own DHCP server running.
In /etc/network/interfaces, configure eth0 and eth1 to receive their settings automatically:

Code: Select all

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp
2) Configure dhclient *not* to update DNS settings:
On Debian-based systems, the default DHCP client implementation is the "isc-dhcp-client".
Edit its config file in /etc/dhcp/dhclient.conf. The default settings look like this:

Code: Select all

request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;
The important options are "domain-name-servers" and "domain-search": Disable them, by commenting them out.

The resulting config block looks like this:

Code: Select all

request subnet-mask, broadcast-address, time-offset, routers, domain-name,
#    domain-name-servers, domain-search,
    host-name, netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;
3) Configure a DNS-forwarding:
Now, when dhclient updates the DHCP leases, it will not use DNS information provided by the DHCP server.
That's good (so there's no interference of DHCPs providing either the one or the other DNS), but now you need DNS-forwarding.

Install "bind9" DNS server package:

Code: Select all

$ apt-get install bind9
Save a copy of /etc/bind/named.conf.options and enter the DNS of your individual networks in the "forwarders {}" section.

For example, if eth0 network is "192.168.100.x/24", and eth1 network is "192.168.200.x/24", which both have their own DNS, at let's say "192.168{100,200}.2", the named.conf.options would look like this:

Code: Select all

options {
    directory "/var/cache/bind";

    // LAN area DNS servers to use:
    forwarders {
        192.168.100.2;
        192.168.200.2;
    };

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
};
Depending on your access patterns, you might want to arrange the lookup-order of the DNS entries so that more-frequently requested domain hostnames are resolved first.

As I've said: I think there's a better way to do it (maybe using resolvconf?), but I haven't figured it out yet.
Good luck!


Links:
Post Reply