Monday, November 23, 2015

DHCP server (basic) configuration in RHEL 6




Open the dhcp configuration file:
# vim /etc/dhcp/dhcpd.conf

// global section of the conf file:
option broadcast-address 192.168.1.255;       //broadcast address
option routers 192.168.1.1;                            // router address
option doamin-name "domain.com"              // domain name
default-lease-time 6000;                               
max-lease-time 72000;

subnet 192.168.1.0 netmask 255.255.255.0 {        // define subnet and netmask
range 192.168.1.10 192.168.1.20;                          // defining range
option domain-name-servers 192.168.1.127, 125.22.47.125;           // defining DNS IP
host system1 {                                                         // defining one host with any name
hardware ethernet 00:1C:23:4C:3B:25;                  // defining MAC address
fixed-address 192.168.1.12;                                   // defining fixed IP address for the host system
}
}

Note: The system having defined MAC address will always get the fixed IP address.
Since the “host block” is defined under “subnet” block-1, and the DNS IPs are defined under it,
the “host” will have access of the DNS system and the Internet as the DNS IPs are defined as globel in the block.

subnet 192.168.1.0 netmask 255.255.255.0 {            // new subnet block
range 192.168.1.21 192.168.1.30;                              // IP range
host system3 {                                                             // defining host
hardware ethernet a1:b2:c3:d4:e5:f3;                       // defining MAC address
fixed-address 192.168.1.22;                                       // defining IP address
}
}

Note: Because no DNS IP is defined in the “subnet” block-2, defined “host” under the block will not have access to the internet.


You can also define the host block in this way:

host system3 {                                                             // defining host
hardware ethernet a1:b2:c3:d4:e5:f3;                       // defining MAC address
fixed-address 192.168.1.22;                                       // defining IP address
option domain-name-servers 192.168.1.127, 125.22.47.125;           // because of the DNS entry                 //  in the “host” block, it will get access to the internet.
}

When dhcpd is running it will generate entries in the file: /var/lib/dhcp/dhcpd.leases:

lease 192.168.1.128 {
starts 2 2004/12/01 20:07:05;
ends 3 2004/12/02 08:07:05;
hardware ethernet 00:00:e8:4a:2c:5c;
uid 01:00:00:e8:4c:5d:31;
client-hostname "Node1";
}

No comments:

Post a Comment