ISC dhcpd: Multiple subnets on one physical wire

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

ISC dhcpd: Multiple subnets on one physical wire

Post by peter_b »

I'm running a setup with 3 physically separated ethernet networks, but 5 IP ranges.
In order to keep the network documented and avoid confusion, the goal is to hand out almost all addresses by a DHCP/DNS combination.

Here's one example network with 2 subnets on 1 physical wire. There are DNS zones configured in "bind" for both subnets.
  • video.local: 192.168.200.x/24
  • storage.local: 192.168.201.x/24
The DHCP configuration for the first subnet "video" (.200) looks like this:

Code: Select all

subnet 192.168.200.0 netmask 255.255.255.0 {
    authoritative;

    option domain-name "video.local";
    option domain-name-servers ns1.video.local, ns2.video.local;

    option router-discovery false;              # Don't auto-detect routers (RFC 1256)

    # multi-DHCP:
    pool {
        #failover peer "dhcp-failover";
        default-lease-time 216000;              # 2.5 days
        max-lease-time 259200;                  # 3 days
        range 192.168.200.200 192.168.200.250;
    }
}
Whereas the DHCP configuration for the second subnet "storage" (.201) is only an empty subnet block:

Code: Select all

    subnet 192.168.201.0 netmask 255.255.255.0 {
        # Only fixed-address will be assigned in this network.
        # Dynamic leases will be offered for video-subnet only.
    }
Now, you need to wrap both these subnet declarations in a "shared-network" block. I've called the physical network "video" (That name is for messages on the logs, for easier debugging):

Code: Select all

shared-network video {
    subnet 192.168.200.0 netmask 255.255.255.0 {
        ....
    }

    subnet 192.168.201.0 netmask 255.255.255.0 {
        ....
    }
}
NOTE: Without the "shared-network" declaration, "fixed-address" assignments for the 2nd subnet (storge) will not work. In that case, clients will receive one from the dynamic pool of the first subnet (video).

Except for temporary hosts/guests, all IPs are assigned by MAC address. For example:

Code: Select all

   host ferry-X {
        hardware ethernet 00:25:90:xx:xx:xx;
        fixed-address ferry-X.video.local;
    }

   host bbX {
        hardware ethernet 00:25:90:xx:xx:xx;
        fixed-address bbX.storage.local;
    }
That's basically it.
If you like, you can wrap "group" around the hosts per-subnet, to assign different nameservers, gateways/routers, etc.
For example:

Code: Select all

group {
   option routers inet.video.local;

   host ferry-X {
        hardware ethernet 00:25:90:xx:xx:xx;
        fixed-address ferry-X.video.local;
    }
}

group {
   option domain-name "storage.local";
   option domain-name-servers ns1.storage.local, ns2.storage.local;
   option routers inet.storage.local;

   host bbX {
        hardware ethernet 00:25:90:xx:xx:xx;
        fixed-address bbX.storage.local;
    }
}
That's basically it. Works like a charm, and keeps the network nice, tidy - and instantly self-documented, by the DHCP/DNS config files! :D
Post Reply