How to Build a DHCP Server in Ubuntu linux
Use a DHCP server to automatically configure the network settings for all computers on your network.
DHCP (Dynamic Host Configuration Protocol) dramatically simplifies the connection of new computers to your network. With a properly configured DHCP server, any new computers you connect will automatically be assigned an IP address, the address of your router, and nameserver addresses. And, to really make things easy on yourself, you can link your DHCP server to the BIND9 DNS server and have new computers automatically assigned a hostname that maps correctly to its dynamically assigned IP address.
Install the DHCP Daemon
First, make sure you don't already have a DHCP server running on your network; two servers providing conflicting information is a recipe for obscure network problems! Install the Internet Software Consortium (ISC) DHCP server:
$ sudo apt-get install dhcp3-server
Basic Configuration
Open the configuration file /etc/dhcp3/dhcpd.conf, where you will see various configuration options that apply both globally and to specific subnets. The majority of the sample options included in the file are quite self-explanatory, so put appropriate entries in the global settings, and then add a basic stanza for your network:
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.20 192.168.0.50;
option routers 192.168.0.1;
}
The range setting specifies the pool of IP addresses to use when new computers connect to your network, and the routers option is passed on so they can add a default route to use to connect to the Internet.
Assign Addresses to Specific Hosts
Sometimes it can be helpful to force specific IP addresses to be associated with certain hosts, such as printers. When a host connects to the DHCP server, it provides the MAC (Media Access Control) address of the network interface, and the DHCP server can then use that to associate the host with a specific configuration.
If you don't know the MAC address of your computer, you can find it printed on a label on most Ethernet cards; network printers often have it labeled somewhere near the Ethernet connector. On Linux, you can obtain it using ifconfig:
$ /sbin/ifconfig eth0 | grep HWaddr
Back on the DHCP server, open /etc/dhcp3/dhcpd.conf and add a stanza near the end for each host:
host workstation51 {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address 192.168.0.51;
}
Make sure the fixed-addresses you set don't fall within a range that has been nominated for general assignment.
Finally, restart the DHCP server so your configuration will take effect:
$ sudo /etc/init.d/dhcp3-server restart
0 Comments