Thursday, December 16, 2010

Debian DHCP Server Setup

Dynamic Host Configuration Protocol (DHCP) is a protocol. It gives client machines "leases" for IP addresses and can automatically set their network configuration.
apt-get -y install rsyslog isc-dhcp-server
Before we start configuring the dhcp server let set our requirements:
  • Domain name: dev.local
  • Network: 192.168.10.0/24
  • DNS Servers: ns1.dev.local, ns2.dev.local
  • Gateway: gw1.dev.local
  • First 40 ip addresses are reserved for servers
  • DHCP pool is 41 - 254

Server Configuration

  1. The server will be listening on eth0 interface (file /etc/default/isc-dhcp-server):
    # On what interfaces should the DHCP server (dhcpd) 
    # serve DHCP requests? Separate multiple interfaces 
    # with spaces, e.g. "eth0 eth1".
    INTERFACES="eth0"
    
  2. Configure DHCP per our requirements (file /etc/dhcp/dhcpd.conf)
    # The ddns-updates-style parameter controls whether or
    # not the server will attempt to do a DNS update when 
    # a lease is confirmed. We default to the behavior of 
    # the version 2 packages ('none', since DHCP v2 didn't
    # have support for DDNS.)
    ddns-update-style none;
    
    # option definitions common to all supported networks
    option domain-name "dev.local";
    option domain-name-servers ns1.dev.local, ns2.dev.local;
    option ip-forwarding off;
    
    # This way you can specify multiple search domains.
    # For Windows clients it doesn't work and need to be
    # setup manually
    option domain-search "dev.local", "corp.local";
    
    # Lease time is in seconds
    default-lease-time 600;
    max-lease-time 7200;
    
    # If this DHCP server is the official DHCP server for 
    # the local network, the authoritative directive should 
    # be uncommented.
    authoritative;
    
    # Use this to send dhcp log messages to a different log 
    # file (you also have to hack syslog.conf to complete 
    # the redirection).
    log-facility local7;
    
    subnet 192.168.10.0 netmask 255.255.255.0 {
      pool {
        range 192.168.10.41 192.168.10.254;
      }
      option subnet-mask 255.255.255.0;
      option broadcast-address 192.168.10.255;
      option routers gw1.dev.local;         
    }
    
    

How to test from Debian client

  1. You need a network interface configured for dhcp (file /etc/network/interfaces):
    allow-hotplug eth0
    iface eth0 int dhcp
    
  2. Obtain ip address and check your up:
    root@dh1:~# dhclient eth0 && ifconfig eth0 | grep inet
              inet addr:192.168.10.41 ...
    
  3. Try some lookups (notice multiple dns search list; in order to use host command you need to install dnsutils package):
    root@dh1:~# host ns1
    ns1.dev.local has address 192.168.10.2
    
    root@dh1:~# host mail
    mail.corp.local has address 192.168.11.10
    

How to enable multi-domain search in Windows client

  1. Choose Advanced TCP/IP Settings
  2. In DNS tab choose "Append these DNS suffixes (in order)"
  3. Add as many as you need domain to search
  4. Try some lookups (notice multiple dns search list):
    C:\>nslookup ns1
    ...
    C:\>nslookup mail
    ...
    
Read more here.

No comments :

Post a Comment