Pages

Saturday, April 15, 2017

DHCP Server

DHCP Server


How to install a DHCP Server on Ubuntu 12.04

The setup is a Ubuntu PC with 4 Ethernet ports.

eth2, eth3, eth4, eth5

Each port is in a separate subnet.

Install the DHCP-Server

apt-get install isc-dhcp-server

Configuration of the DHCP Server

At first define the interfaced to be used in the file /etc/default/isc-dhcp3-server


INTERFACES="eth2 eth3 eth4 eth5"

In a second step the subnets need to be defined. For this, the interface and the address range needs to be defined for each net. The lease times can be defined global for all nets. To prevent any other DHCP Server to interract with your subnet, the Server is set in authoritative mode.  All this settings are to be done in the file /etc/dhcp/dhcpd.conf.


authoritative;

default-lease-time 600;
max-lease-time 7200;


subnet 192.168.150.0 netmask 255.255.255.0 {
range 192.168.150.10 192.168.150.250;
interface eth2;
option broadcast-address 192.168.150.255;
}


subnet 192.168.151.0 netmask 255.255.255.0 {
range 192.168.151.10 192.168.151.250;
interface eth3;
option broadcast-address 192.168.151.200;
}

subnet 192.168.152.0 netmask 255.255.255.0 {
range 192.168.152.10 192.168.152.250;
interface eth4;
option broadcast-address 192.168.152.255;
}

subnet 192.168.153.0 netmask 255.255.255.0 {
range 192.168.153.10 192.168.153.250;
interface eth5;
option broadcast-address 192.168.153.255;
}

At last the interfaces need to be added to the subnets itself. Therefore just define the interfaces in the file /etc/network/interfaces by adding this lines.


auto eth2
iface eth2 inet static
address 192.168.150.1
netmask 255.255.255.0

auto eth3
iface eth3 inet static
address 192.168.151.1
netmask 255.255.255.0

auto eth4
iface eth4 inet static
address 192.168.152.1
netmask 255.255.255.0

auto eth5
iface eth5 inet static
address 192.168.153.1
netmask 255.255.255.0

The following commands help to control the DHCP Server when trying out the changes


sudo service isc-dhcp-server restart
sudo service isc-dhcp-server start
sudo service isc-dhcp-server stop

Source:

http://askubuntu.com/questions/201746/dhcp-server-with-multiple-interfaces-on-ubuntu-destroys-default-gateway

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.