dhcp
when you need to change the network configuration, say to update a DNS server, all you need to do is update the DHCP server and all the connected hosts will be reconfigured with new settings.
DHCP is most commonly used to provide IP configuration settings, such as IP address, net mask, default gateway, and DNS servers. However, it can also be set to configure the time server and hostname on the client.
DHCP can be configured to use the following configuration methods:
- Manual allocation: Here, the configuration settings are tied with the MAC address of the client's network card. The same settings are supplied each time the client makes a request with the same network card.
- Dynamic allocation: This method specifies a range of IP addresses to be assigned to the clients. The server can dynamically assign IP configuration to the client on first come, first served basis. These settings are allocated for a specified time period called lease; after this period, the client needs to renegotiate with the server to keep using the same address. If the client leaves the network for a specified time, the configuration gets expired and returns to pool where it can be assigned to other clients. Lease time is a configurable option and it can be set to infinite.
Ubuntu comes pre-installed with the DHCP client,
dhclient
. The DHCP dhcpd
server daemon can be installed while setting up an Ubuntu server or separately with the apt-get
command.
Follow these steps to install a DHCP server:
- Install a DHCP server:
$ sudo apt-get install isc-dhcp-server
- Open the DHCP configuration file:
$ sudo nano -w /etc/dhcp/dhcpd.conf
- Change the default and max lease time if necessary:
default-lease-time 600; max-lease-time 7200;
- Add the following lines at the end of the file (replace the IP address to match your network):
subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.150 192.168.1.200; option routers 192.168.1.1; option domain-name-servers 192.168.1.2, 192.168.1.3; option domain-name "example.com"; }
- Save the configuration file and exit with Ctrl + O and Ctrl + X.
- After changing the configuration file, restart
dhcpd
:$ sudo service isc-dhcp-server restart
You can reserve an IP address to be assigned to a specific device on network. Reservation ensures that a specified device is always assigned to the same IP address. To create a reservation, add the following lines to
dhcpd.conf
. It will assign IP 192.168.1.201
to the client with the 08:D2:1F:50:F0:6F
MAC ID:host Server1 { hardware ethernet 08:D2:1F:50:F0:6F; fixed-address 192.168.1.201; }
Comments
Post a Comment