Monday, December 26, 2011

Linux DHCP Server Configuration

[root@mail ~]# rpm -qa | grep dhcp*
dhcpv6-client-1.0.10-17.el5
dhclient-3.0.5-21.el5

[root@ns1 /]# yum install dhcp* -y
[root@ns1 /]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc
[root@mail ~]# cd /etc/
[root@localhost etc]# mv dhcpd.conf.sample dhcpd.conf
mv: overwrite `dhcpd.conf'? y 

[root@localhost etc]# vim /etc/dhcpd.conf  
ddns-update-style interim;
ignore client-updates; 

subnet 192.168.100.0 netmask 255.255.255.0 { 
# --- default gateway
        option routers                       192.168.100.1;
        option subnet-mask              255.255.255.0; 

        option nis-domain                      "domain.org";
        option domain-name                  "domain.org";
        option domain-name-servers      192.168.100.1;

        option time-offset                      -18000; # Eastern Standard Time
#       option ntp-servers                     192.168.1.1;
#       option netbios-name-servers     192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

        range dynamic-bootp 192.168.100.2 192.168.100.254;
        default-lease-time 21600;
        max-lease-time 43200;

# we want the nameserver to appear at a fixed address
        host ns1 {
                next-server marvin.redhat.com;
                hardware ethernet 
00:0C:42:53:BC:F4 ;
                fixed-address 192.168.100.5;
                }
            host ns2 {
                hardware ethernet 08:00:27:CA:74:C4 ;
                fixed-address 192.168.100.240;
        }

}

[root@localhost etc]# chkconfig dhcpd on
[root@localhost etc]# /etc/init.d/dhcpd restart
Starting dhcpd:                                            [  OK  ]
 

[root@ns1 ~]# ping 192.168.50.21
PING 192.168.50.21 (192.168.50.21) 56(84) bytes of data.
64 bytes from 192.168.50.21: icmp_seq=1 ttl=128 time=0.388 ms
64 bytes from 192.168.50.21: icmp_seq=2 ttl=128 time=0.535 ms

--- 192.168.50.21 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1006ms
rtt min/avg/max/mdev = 0.388/0.461/0.535/0.076 ms
[root@ns1 ~]# arp -a
? (192.168.50.21) at 00:0C:42:53:BC:F4 [ether] on eth0


[root@mail ~]# ping 192.168.50.56
PING 192.168.50.56 (192.168.50.56) 56(84) bytes of data.
64 bytes from 192.168.50.56: icmp_seq=1 ttl=64 time=0.588 ms
64 bytes from 192.168.50.56: icmp_seq=2 ttl=64 time=0.401 ms

--- 192.168.50.56 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.401/0.494/0.588/0.096 ms
[root@ns1 ~]# arp -a
(192.168.50.56) at 08:00:27:CA:74:C4 [ether] on eth0