DHCP -Ameeta and Haripriya -cmsc 691x
DHCP ► Dynamic Host Configuration Protocol ► It controls vital networking parameters of hosts with the help of the server ► Its an extension of BOOTP ► Its backward compatible with BOOTP existing BOOTP devices can communicate with DHCP servers and allow the DHCP requests to cross routers running BOOTP forwarders Upgrading is easy
DHCP CLIENT SETUP ► Download dhcpcd from one of the following sites ftp://metalab.unc.edu/pub/Linux/system/network/daem ons ftp://metalab.unc.edu/pub/Linux/system/network/daem ons ftp://metalab.unc.edu/pub/Linux/system/network/daem ons ftp://ftp.phystech.com/pub/ ftp://ftp.phystech.com/pub/ ► Unpack it Tar –zvxf dhcpd pl1.tar.gz ► Cd into the directory and make dhcpcd Cd dhcpcd pl1 Make ► Install it Make install
DHCP CLIENT SETUP ► /etc/dhcpc will be created. ► DHCPcd will store the DHCP information. ► dhcpcd will be copied into /usr/sbin ► To make system initialize during DHCP during boot type cd /etc/rc.d cd /etc/rc.d ► Then do “mv rc.inet1 rc.inet1.OLD” ► This moves old network initialization script into “rc.inet1.OLD” ► Create the new rc.inet1 script. ► Save it and reboot the computer.
Sample code in rc.net ► #!/bin/sh ► # ► # rc.inet1 This shell script boots up the base INET system. ► HOSTNAME=`cat /etc/HOSTNAME` ► #This is probably not necessary but I will leave it in anyways ► # Attach the loopback device. ► /sbin/ifconfig lo /sbin/route add -net netmask lo # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the # eth0 interface. If you're only using loopback or SLIP, don't include the # rest of the lines in this file ►. /usr/sbin/dhcpcd
DHCP CLIENT SETUP ► After machine reboots the network interface should be configured. ► Type ifconfig ► If we have some normal no under inet addr that means we are set. ► One final thing is we need to specify our nameservers. ► Two ways to do it: ► Ask the provider for the address of the nameserver and then put those in “/etc/resolv. conf” ► Or DHCPcd will obtain the list from DHCP server and will build resolv.conf in “/etc/dhcpc”.
DHCP CLIENT SETUP ► Make a link from “/etc/dhcpc/resolv.conf” to “/etc/resolv.conf by using: ln –s /etc/dhcpc/resolv.conf /etc/resolv.con ► This was all about setting up the client for DHCP.
DHCP Server Setup ► Download the DHCP server from ftp://ftp.isc.org/isc/dhcp/. ftp://ftp.isc.org/isc/dhcp/ ► Unpack it. ► cd into the distribution directory and type “./configure”. ► Type “make” ► Type “make install”. ► After installing type “ifconfig –a”. ► If the resulting output does not say MULTICAST then we must reconfigure the kernel and add multicast support.
DHCP Server Setup ► Add route for ► Type “route add –host dev eth0” ► If we get a message “ : Unknown host” ► In /etc/hosts files add “ all-ones”. ► Then do,” route add –host all-ones dev eth0” ► Eth0 is the name of the network device you use. ► If it differs change appropriately.
DHCP Server Setup ► To configure DHCPd create or edit “/etc/dhcpd.conf”. ► There is a graphical interface for dhcpd configuration under KDE called “kcmdhcpd”. ► It is very similar to DHCP configurator on Windows NT. ► To configure by hand instructions are discussed below. ► To assign IP addresses randomly the settings in /etc/dhcpd.conf will be as shown. ► A sample /etc/dhcpd.conf will contain:
DHCP Server Setup. ► #sample /etc/dhcpd.conf ► default-lease-time 600; ► max-lease-time 7200; ► option subnet-mask ; ► option broadcast-address ; ► option routers ; ► option domain-name-servers , ; ► option domain name “mydomain.org”; ► subnet netmask { ► range ; ► range ; ► }
DHCP Server Setup ► We can also assign specific IP addresses based on the client’s ethernet address. ► Eg. host haagen { ► hardware ethernet 08:00:2b:4c:59:23; ► fixed-address ; ► } ► This will assign IP address to a client with the ethernet address mentioned above. ► Create the dhcpd.leases file which has information about current leases.
DHCP Server Setup ► Do “touch /var/state/dhcp/dhcpd.leases” to create empty dhcpd.leases file. ► Invoke the DHCP server by typing “/usr/sbin/dhcpd” ► This will invoke dhcpd on etho device. ► To verify everything is working fine : ► Turn on the debugging mode ► Put the server in foreground. ► “/usr/sbin/dhcpd –d –f “ ► Then boot one of the clients and check out console of server.
DHCP Server Setup ► We would see no of debugging messages coming up. ► If everything is fine then the setup is done. ► You can quit dhcpd. ► If we want dhcpd to start at boot-up include dhcpd in “/etc/rc.d/rc.local”. ► Now we are done with DHCP Server Setup.