Install and Configure quickly a DHCP Server
NOTE: These commands have been tested in Debian version unstable.
DHCP stands for Dynamick Host Configuration Protocol. This protocol allows to automatically obtain an IP address and set the network configuration.
We install a DHCP server:#aptitude install dhcp3-server
Next step is configuring the DHCP server:
We have to set correcty the /etc/dhcp3/dhcpd.conf
file.
There is a configuration file example at:/usr/share/doc/dhcp3-server/examples/dhcpd.conf
e.g: I added these lines to my /etc/dhcp3/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.252 {
range 192.168.1.2 192.168.1.3;
option routers 192.168.1.1;
option domain-name-servers 212.73.32.3, 212.73.32.67;
}
subnet and netmask indicate the network addresses of our network:
e.g: subnet 192.168.1.0 netmask 255.255.255.252 match 192.168.1.0, 192.168.1.1, 192.168.1.2 and 192.168.1.3 IP addresses.
range means which addresses can be returned by our dhcp server, here, it can return 192.168.1.2 and 192.168.1.3
routers indicates the gateway
domain-name-servers shows all dns addresses separated by commas.
Once we have correctly set dhcpd.conf file we restart the dhcp daemon:
#/etc/init.d/dhcp3-server restart
If everything has gone fine, we will execute in a client computer:
$sudo dhclient eth0
and the dhcp server will associate an IP adress to eth0 interface.
NOTE: dhcp3-client package provides dhclient command.
#aptitude install dhcp3-client