Help - Search - Members - Calendar
Full Version: Setting Up One Dhcp Server For
Linuxhelp > Support > Guides Forum
Robert83
In this step-by-step guide I will show you how you can install a dhcp server for each subnet without having that ping-pong effect , that one dhcp server sends the cliend DHCPNACK and the other DHCPACK and causes delays from 5-30 even 60 seconds sometimes. I decieded to write this guide , since I think we have a problem regarding dhcp manuals, I was googling for 2 days and only found basic settings for dhcp servers, no tutorials or examples on how to set up a dhcp server for each subnet.

** This step-by-step guide though tested only on WBEL 3.0 should work without any problems with other distros using the latest stable dhcp server package

So here we go :

first let's take a look at our example network :

We have three subnets 192.168.0.x ; 192.168.1.x and 192.168.2.x
each of them located in the city 2 km (minimum) from each other.
They are connected together via wireless network to allow them connection to the internet.
The problem in this situation is , that wireless connection wont work sometimes due to really bad weather condition or electrical failure (they are really sensitive , even our current Pheenet wireless BRIDGE/ACCESPOINT's fail sometimes though very rare (and they cost around 200Eur here)). So putting up a DHCP server at the Gateway or at one of three sites is not reliable enough, what if for some reason one of the sites would fail at the wrong hour and a entire subnet would not be able to connect to their local server because they didn't get a valid ip address...well the boss would be in a very-very bad mood, so I can't allow this to happen.

So here are the example configuration files :

The first dhcp server will be responsible to subnet 192.168.0.0 and will ignore (yes ignore, won't send DHCPNACK or anything at all back like no free lease etc...just ignore other clients, which is the right thing to do in this situation)

CODE
yum update
yum install dhcp


once dhcp is installed ...
CODE
touch /etc/dhcpd.conf
vi /etc/dhcpd.conf

and write the following into it :
ddns-update-style interim;
not authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
default-lease-time 86400;
max-lease-time 86400;
option broadcast-address 192.168.0.255;
option routers 192.168.0.250;
option domain-name-servers 192.168.0.250;
option netbios-name-server 192.168.1.200; (aka WINS server)
}

host user1 {
hardware ethernet xx:xx:xx:xx:xx:xx;
fixed-address 192.168.1.10; (it's good to begin from 10 since some idiotic Wireless cards
default to 192.168.1.1 smile.gif )
}

...

host usern {
hardware ethernet xx:xx:xx:xx:xx:xx;
fixed-address 192.168.1.n;
}
(I have 45 hosts defined like this in my config ... and it works okay)

CODE
/etc/init.d/dhcpd stop
/etc/init.d/dhcpd start


the second dhcp server will be responsible to 192.168.1.0 and will ignore all the other clients

** use the same procedure as above to install the dhcp server and use the same configuration procedure, offcourse the subnet part will be different and all the clients as well

!!!DANGER!!! NEVER EVER use authoritative in these config files !!! NEVER EVER!
only use not authoritative at the top, that is all.

if you check your log files now you can see that on the dhcp server that is supposed to give out that specific ip address to that mac address (/var/log/messages)
DHCPDISCOVER from xx:xx:xx:xx:xx:xx via eth0
DHCPOFFER on 192.168.1.23 to xx:xx:xx:xx:xx:xx via eth0
DHCPREQUEST for 192.168.1.23 (192.168.1.200) from xx:xx:xx:xx:xx:xx
DHCPACK on 192.168.1.23 to xx:xx:xx:xx:xx:xx

while the dhcp server that ignored it show the following in it's log file :

DHCPDISCOVER from xx:xx:xx:xx:xx:xx via eth0: netowrk 192.168.2.0/24: no free leases
DHCPREQUEST for 192.168.1.23 (192.168.2.200) from xx:xx:xx:xx:xx:xx via eth0: ignored (not authoritative)

note: sometimes the log files will show that you should set authoritative if it's authoritative for this and that...but it works...

Sincerely
Robert B
Corey
Nice little guide, out of curiosity, is it possible in linux to set up a dhcp server on one subnet and setup dhcp relays on the other 2? I know this is not what you want in your situation because of the unreliableness of wireless (hey, that rhymes). I know how to do this in Windows, just wondering how it would be done in linux.
Robert83
Hi,

you need to have the dhcp package installed

man dhcrelay

for example... to relay to some other dhcp server

CODE
dhcrelay 192.168.2.200


Sincerely
Robert B
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.