Configure DHCP Server
DHCP Configuration Files
- /etc/dhcpd.conf
- service dhcpd start
- /etc/dhcp/dhcpd.conf
- /var/lib/dhcpd/dhcpd.leases
How to configure DHCP server:
- Install the dhcp package as the superuser
- Once dhcp package is installed it creates /etc/dhcp/dhcpd.conf with empty configuration file.
- Sample DHCP configuration file can be found at /usr/share/doc/dhcp-<version>/dhcpd.conf.sample. Taking this sample file as reference can build /etc/dhcp/dhcpd.conf file.
- DHCP also uses the file /var/lib/dhcpd/dhcpd.leases to store the client lease database.
How to use '/etc/dhcp/dhcpd.conf' configuration file:
Configuration file has two important statements:
- Parameters — Parameters defines how to perform a task, weather to perform a task or not and network configuration settings what needs to be send to the client.
- Declarations — Declarations describe the network topology, client registrations, IP address details assigned for clients.
Below configuration declaring subnet range and static IP address for clients using DHCP as network configuration.
dhcpd services must be restarted if any configuration changes to the configuration file /etc/dhcp/dhcpd.conf'
#service dhcpd restart
Explain /etc/dhcp/dhcpd.conf (Important Options)
- subnet 192.168.1.0 netmask 255.255.255.0
- Describes a network with an address of 192.168.1.0 and a subnet mask of 255.255.255.0. This block assign addresses in the range 192.168.1.1–192.168.1.254 to different systems on this network.
- option subnet-mask 255.255.255.0
- Specifies the subnet mask for the network.
- option domain-name
- Adds the domain name for your network.
- option domain-name-servers 192.168.1.1,192.168.1.2
- Use the IP address for the DNS server for your network.
- default-lease-time
- Specifies the lease time for IP address information,in seconds.
- max-lease-time
- Specifies the maximum lease time for IP address information,in seconds.
Eveytime client system gets restarted it gets register with DHCP server and DHCP server may assign IP address from the configured subnet range. The IP address may change every time the the client gets registered. or When Client renew IP address lease the IP may vary and its all dynamic change of DHCP server.
- hardware-ethernet 00:A0:78:8E:9E:AA
- DHCP server matches the client ethernet MAC address and it ensures that every time the IP has to be renewed the fixed IP address will be assigned.
- fixed-address 192.168.1.4
- When MAC address is matched then this fixed-address will be leased to the client machine and server ensures that every time client gets same IP address.
DHCP Client:
- Configure eth0 configuration by specifying “BOOTPROTO=dhcp” so, that client follows “DORA” protocol to get dynamic IP for lease from DHCP server.
kloudways spots:
- DHCP (Dynamic Host Configuration Protocol) allows a client computer to obtain network information (such as an IP number) from a server.
- The bootp protocol allows a client computer to access a DHCP server on a remote network.
- DHCP servers are configured through /etc/dhcpd.conf.
- Remember that the DHCP server daemon is dhcpd; the DHCP client daemon is dhclient.
Previous
Next