M HYPE SPLASH
// general

Ubuntu How to setup Multi Dhcp Server

By Emma Payne

If you have 2 NIC (network Lan card) each connected to different networks:

=> eth0: 192.168.1.0/24

=> eth1: 192.168.2.0/24

I need the Dhcp server to serve the different subnets ip leases ?

How to check the leases ?

Can the two subnets ping each others ?

1 Answer

First install dhcp package :

sudo apt-get install isc-dhcp-server

Second edit dhcp default interface that should serve dhcp leases :

sudo gedit /etc/default/isc-dhcp-server

# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/isc-dhcp-server by the maintainer scripts
#
# This is a POSIX shell fragrmnt
#
# On what interfaces shauld the [MCP server (dhcpd) serve MCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="eth0 eth1"

eth0 and eth1 will serve dhcp

Third edit the dhcp conf file to set ranges :

sudo gedit /etc/dhcp/dhcpd.conf
# A slightly different configuration far an internal subnet.
subnet 192.188.1.6 netmask 255.255.255.0 { range 192.168.1.5 192.168.1.15; option domain-name-servers ns1.domain.org; option domain-name "domain.org"; option routers 192.168.1.2; option broadcast-address 192.168.1.255; default-lease-time 600; max-lease-time 7200;
}
# A slightly different configuration far an internal subnet.
subnet 192.168.2.0 netmask 255.255.255.0 { range 192.168.2.5 192.168.2.15; option domain-name-servers ns2.domain.org; option domain-name "domain2.org"; option routers 192.168.2.2; option broadcast-address 192.168.2.255; default-lease-time 600; max-lease-time 7200;
}

Now restart the service :

 sudo service isc-dhcp-server

Dhcp server is active now and the network will be server by the two ranges .

To make a reservation for a printer example :

host printer1 { hardware ethernet 00:1A:6B:6A:2E:0B; fixed-address 192.168.1.90;
}
host printer2 { hardware ethernet 00:1A:6B:6A:2E:0B; fixed-address 192.168.2.90;
}

To check the leases from dhcp server :

gedit /var/lib/dhcp/dhcpd.leases

The last question can the two subnets ping each other :

Make 192.168.2.* Accessible from 192.168.1.*

Now we need to add a routing entry such that we are able to ping 192.168.2. series

ip-addresses from 192.168.1. series. The common point we have is the GATEWAY machine.

So, on each machine in 192.168.1.* network a default gateway will be added as shown below.

route add default gw 192.168.1.2

Now when 192.168.1.5 pings 192.168.2.7, it will go to the GATEWAY via 192.168.1.2.

In GATEWAY, add the following routing entry.

route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.2

Now all the packets addressed to 192.168.2.* network will be forwarded via the

192.168.2.2 interface, which then delivers the packets to the addressed machine.

Make 192.168.1.* Accessible from 192.168.2.*

It is very similar to what we did earlier.

So, on each machine in 192.168.2.* network a default gateway will be added as shown below.

route add default gw 192.168.2.2

In GATEWAY, add the following routing entry.

route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.2

Now 192.168.2.* machines can ping 192.168.1.* machines.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy