Setting Up Multiple Subnets on One Interface

Using Linux and ISC DHCPd you can successfully setup multiple IP subnets on the same interface by creating a Shared Network.

# ifconfig
eth1 Link encap:Ethernet HWaddr 00:00:00:00:00:00
  inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
...[snip]...
eth1:1 Link encap:Ethernet HWaddr 00:00:00:00:00:00
  inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1:2 Link encap:Ethernet HWaddr 00:00:00:00:00:00
  inet addr:192.168.20.1 Bcast:192.168.20.255 Mask:255.255.255.0
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1:3 Link encap:Ethernet HWaddr 00:00:00:00:00:00
  inet addr:192.168.30.1 Bcast:192.168.30.255 Mask:255.255.255.0
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Example /etc/dhcpd.conf
ddns-update-style ad-hoc;
option netbios-name-servers 192.168.1.1;
option domain-name-servers 192.168.1.1;
option domain-name "somedomain.com";
option subnet-mask 255.255.255.0;
# sharednetworks
shared-network sharednetworks {
  allow unknown-clients;
  authoritative;
# Level 10
  subnet 192.168.10.0 netmask 255.255.255.0 {
  option broadcast-address 192.168.10.255;
  option routers 192.168.10.1;
  range 192.168.10.100 192.168.10.200;
# Host A
  host hostA {
  hardware ethernet 00:00:00:00:00:00;
  fixed-address 192.168.10.2;
  }
}
# Level 20
  subnet 192.168.20.0 netmask 255.255.255.0 {
  option broadcast-address 192.168.20.255;
  option routers 192.168.20.1;
  range 192.168.20.100 192.168.20.200;
host hostB {
  hardware ethernet 00:00:00:00:00:00;
  fixed-address 192.168.20.2;
}
}
# Level 30 – default network for all clients
  subnet 192.168.30.0 netmask 255.255.255.0 {
  allow unknown-clients;
  authoritative;
  option broadcast-address 192.168.30.255;
  option routers 192.168.30.1;
  range 192.168.30.100 192.168.30.200;
host hostC {
  hardware ethernet 00:00:00:00:00:00;
  fixed-address 192.168.30.2;
  }
  }

References:
Dhcpd unable to serve multiple subnets
ISC DHCP FAQs
Internet Systems Consortium, Inc. (ISC) – DHCPd Server


About this entry