Tuesday 1 March 2011

Configure Dhcp Server with Red Hat Linux

1. Configure /etc/dhcpd.conf -
                  Does not exist by default
          Copy sample from the DHCP documentation.[ i.e Do this : # cp dhcpd.conf.sample /etc/dhcpd.conf ]
                  Delete everyting in it and keep this much


 Now your new /etc/dhcpd.conf should look like this :
  vi /etc/dhcpd.conf
   ================
   ddns-update-style interim;
   ignore client-updates;
   
    subnet 192.168.0.0 netmask 255.255.255.0
    {
   
      # The range of IP addrs the server will issue to DHCP enabled PC clients
      # booting up on the network
   
        range 192.168.0.100 192.168.0.120;   

      # Set the amount of time in seconds that a client may keep the IP address
     
    default-lease-time 21600;
    max-lease-time 43200;

      # Set the default Gateway to be used by the PC clients
      # This put the word --> GATEWAY=192.168.0.1 in ../ifcfg-eth0

        option routers 192.168.0.1;

      # Don't forward DHCP requests from this NIC interface to any other NIC
      # interfaces
      # Put this on if you have multiple NICs

        option ip-forwarding off;

      # Set the broadcast address and subnet mask to be used by the DHCP clients

        option broadcast-address 192.168.0.255;
    option subnet-mask 255.255.255.0;

      # Set the DNS server to be used by the DHCP clients
      # This puts the word --> nameserver=192.168.0.100 in /etc/resolv.conf

        option domain-name-servers 192.168.0.100;

      # If you specify a WINS server for your Windows clients, include this :
 
        option netbios-name-servers 192.168.1.100;

      # You can also assign specific IP addresses based on the clients'
      # ethernet MAC address as follows (Host's name is "laser-printer")
       
    host laser-printer
    {
      hardware ethernet 08:00:2b:4c:59:23;
      fixed-address 192.168.0.222;
    }
    }

2. touch /var/lib/dhcp/dhcpd.leases   or else DHCP server will NEVER start
                                      and not required from RH7.2 onwards  bcos it already exists

3. service dhcpd start

4.set dhcpd for auto run
       chkconfig --list dhcpd
      dhcpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off

      chkconfig dhcpd on
     dhcpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off


 Testing :-------

 dhcpd -f  - whether DHCP server is up and running
 dhcpd -T  - if dhcpd.leases is OK
 dhcpd -t  - if dhcpd.conf syntax is OK

See man dhcp-options

  Client ------

1. /etc/sysconfig/network-scripts/ifcfg-eth0    Change static to dhcp
    or
    use netconfig

2. reboot or service network restart or even better "ifdown/ifup eth0"

What all can a DHCP server provide Clients ?

1. IP                  - range
2. netmask             - option subnet-mask
3. BC                  -  boot Client
4. nameserver          - 'option domain-name-servers'
5. domain              - 'option domain-name'
6. NIS domain          - 'option nis-domain-name'
6. MAC addr-based IP   - 'hardware ethernet' and 'fixed-address'
7. default lease time  - 'default-lease-time'
8. max lease time      - 'max-lease-time'
9  gateway             - 'option routers'
   For netbios/Samba      option netbios-node-type 2
                          option netbios-name-server


0 comments:

Post a Comment