DHCP server for multilple VLANs [duplicate]

Solution 1:

if your linux router has trunk interface to the switch with tagged vlans you can do it without problems.

first define each vlan in /etc/network/interfaces eg:

auto eth0.200
iface eth0.200 inet static
 address 10.0.1.1
 netmask 255.255.255.0


iface eth0.201 inet6 static
 address 10.0.2.1
 netmask 255.255.255.0


iface eth0.202 inet6 static
 address 10.0.3.1
 netmask 255.255.255.0

then tell dhcp daemon to listen on some/all of those subnets by editing /etc/default/isc-dhcp-server [or dhcpd] and changing variable INTERFACES to "eth0.200 eth0.201 eth0.202"

and adding separate subnets to /etc/dhcp/dhcpd.conf

subnet 10.0.1.0 netmask 255.255.255.0 {
  range 10.0.1.10 10.0.1.20;
  # you might point some other address 
  # within that subnet that should be advertised as router
  # it does not have to be your linux box
  option routers 10.0.1.1;
  option broadcast-address 10.0.1.255;
  authoritative;
}

and so on for the rest of subnets.

Solution 2:

To create multiple VLAN on your server, you will need a switch with 802.1q (VLAN Tagging or Trunk in Cisco terminology) enable or multiple physical interface. The DHCP server will listen requests on each interface. You can define the distributed addresses for each interface.

The clients are connected on one VLAN, the broadcast the IP request. Your server receive the request and then answer to the range defined for this VLAN.

Do you have a switch with 802.1q support ? Or do you have multiple interfaces on your server ?

Solution 3:

If you router is a Linux box, then you need to install a DHCP relay. The most common is the ISC package isc-dhcp-relay.

Once you install it you must give it a list of every interface that it will be relaying DHCP to and from, and you must provide the IP address of the DHCP server. The config file is /etc/default/isc-dhcp-relay.

The name of the package has changed once in the last couple years, so if you are running an older version of Ubuntu the package might be named different.

  • http://packages.ubuntu.com/precise/isc-dhcp-relay
  • http://packages.ubuntu.com/lucid/dhcp3-relay