This is a simple guide installation of DHCP service on Debian Linux (7.7 wheezy). First you need to know which interface the service will be listening (normally this eth0) and next the current IP subnet where this server is running. This could be the same IP subnet you plan leasing. Next you need to get the information about the IP subnet this service will be leasing.
In this guide, we will be using this IP subnet.
Subnet: 192.168.100.0
Netmask: 255.255.255.0
Range: 192.168.100.100 192.168.100.200 # These are the IP address range to be lease to end devices
Gateway: 192.168.100.1 # This gateway to the rest of the network (i.e. Internet)
Domain Name Servers: 192.168.200.11 192.168.200.12 # These are your DNS servers
Domain Name: HOME.NET # This is important if you have a DOMAIN or WORKGROUP
Subnet: 192.168.100.0
Netmask: 255.255.255.0
Range: 192.168.100.100 192.168.100.200 # These are the IP address range to be lease to end devices
Gateway: 192.168.100.1 # This gateway to the rest of the network (i.e. Internet)
Domain Name Servers: 192.168.200.11 192.168.200.12 # These are your DNS servers
Domain Name: HOME.NET # This is important if you have a DOMAIN or WORKGROUP
Install the required package
# apt-get install isc-dhcp-server isc-dhcp-common
After installation, don't worry if the word "failed" came out. We just need to modify the configuration file get things working. Edit /etc/dhcp/dhcpd.conf and add/modify these lines
option domain-name "HOME.NET";
option domain-name-servers 192.168.200.1, 192.168.200.12;
subnet 192.168.100.0 netmask 255.255.255.0
{ range 192.168.100.100 192.168.100.200;
option routers 192.168.100.1;
# default-lease-time 600;
# max-lease-time 7200;
}
Start the DHCP service
# /etc/init.d/isc-dhcp-server start
Starting ISC DHCP server: dhcpd.
Verify and check if the services is running.
# ps ax | grep dhcp
22921 ? Ss 0:00 /usr/sbin/dhcpd -q -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid
# netstat -tanup | grep dhcp
udp 0 0 0.0.0.0:67 0.0.0.0:* 22921/dhcpd
udp 0 0 0.0.0.0:29114 0.0.0.0:* 22921/dhcpd
udp6 0 0 :::39673 :::* 22921/dhcpd
The output for ps shows if the proces is indeed running while the output for netstat shows if the DHCP service is listening on UDP port 67 both for IPv4 and IPv6. Dont worry about UDP port 29114 as this is for inter-process communication. For paranoid administrator, you can firewall this. Check/update for any firewall rules if needed (iptables -L -n -v).
When in operation, you can check any leased IP address by checking the DHCP lease file (tail -f /var/lib/dhcp/dhclient.leases). You can check DHCPStatus for a simple web interface.
Check the syslog output for any errors (tail /var/log/syslog). Below is the most common errors if the DHCP server is running on a different subnet than the IP subnet being leased.
When in operation, you can check any leased IP address by checking the DHCP lease file (tail -f /var/lib/dhcp/dhclient.leases). You can check DHCPStatus for a simple web interface.
Check the syslog output for any errors (tail /var/log/syslog). Below is the most common errors if the DHCP server is running on a different subnet than the IP subnet being leased.
Jan 7 08:16:50 testprobe dhcpd: No subnet declaration for eth0 (192.168.100.11).
Jan 7 08:16:50 testprobe dhcpd: ** Ignoring requests on eth0. If this is not what
Jan 7 08:16:50 testprobe dhcpd: you want, please write a subnet declaration
Jan 7 08:16:50 testprobe dhcpd: in your dhcpd.conf file for the network segment
Jan 7 08:16:50 testprobe dhcpd: to which interface eth0 is attached. **
Jan 7 08:16:50 testprobe dhcpd:
Jan 7 08:16:50 testprobe dhcpd:
Jan 7 08:16:50 testprobe dhcpd: Not configured to listen on any interfaces!
Add this line on the configuration file (etc/dhcp/dhcpd.conf) as the server is on a different subnet (i.e. eth0 = 192.168.100.11)
subnet 192.168.100.0 netmask 255.255.255.0 { }