Configuring basic DHCP server

From Notes_Wiki
Revision as of 08:47, 4 August 2016 by Saurabh (talk | contribs)

<yambe:breadcrumb>Dhcp_server_configuration|Dhcp server configuration</yambe:breadcrumb>

Configuring basic DHCP server

To configure basic DHCP server install 'dhcp' package. Then edit '/etc/dhcp/dhcpd.conf' file so that it has contents similar to:

subnet <network-1> netmask <netmask-1>
{

}

subnet 192.168.100.0 netmask 255.255.255.0
{
       option domain-name "rekallsoftware.com";
       option domain-name-servers 192.168.100.1;
       option routers 192.168.100.1;
       range 192.168.100.50 192.168.100.150;

       host hp_laserjet_m1536dnf_1 { hardware ethernet 2c:59:e5:d6:51:dd; fixed-address 192.168.100.4; }

}

Please note following points:

  1. For every interface of router a corresponding subnet must be present in dhcpd.conf file for DHCP server to work
  2. Additional subnets can be defined which are useful if 'ip helper-address' type of configuration is done on L3 switch where VLAN is defined. This would allow forwarding DHCP requests for other VLAN to DHCP server even when DHCP server is not in same subnet.
  3. Defined subnets can be completely empty or could have configuration lines as shown in example above.
  4. Static IP address can be mapped to a particular MAC address in DHCP server. This setting can be done for each subnet separately if same host understandably needs different IP in each subnet.
  5. After all changes to dhcpd.conf file, 'service dhcpd restart' is required
  6. All dynamic IP addresses assigned by DHCP can be seen in '/var/lib/dhcpd/dhcpd.leases' file. If this file is edited manually then restart server again. Static addresses will not appear in leases file. Addresses bound using "host __ {hardware ethernet __; fixed-address __; }" also do not appear in dhcpd.leases file


DHCP server setup in CentOS 7.0

For CentOS 7.0 the above steps should work. Optionally firewalld can be configured using:

firewall-cmd --add-service=dhcp --permanent
firewall-cmd --reloa

Add '--zone' appropriately if zones are used.

Refer http://www.server-world.info/en/note?os=CentOS_7&p=dhcp



<yambe:breadcrumb>Dhcp_server_configuration|Dhcp server configuration</yambe:breadcrumb>