Monday, November 7, 2011

Install and configure DHCP server

This blog entry describes how you would install and configure the dhcpd (DHCP) server for the purpose of assigning an IP address to machines booting up via the network and pointing these machines to the PXE boot environment.

The PXE boot environment (TFTP server) is documented in another blog entry Install and configure tftp server for PXE boot environment and the main entry discussion on Network Installation of openSUSE.

1) Install DHCP Server (dhcpd)

Command-line (as root): zypper in dhcp-server yast2-dhcp-server



2) Configure DHCP

Make a backup of the dhcpd.conf file to start afresh: mv /etc/dhcpd.conf /etc/dhcpd.org.conf

Create a new dhcpd.conf file, using your favourite text editor as root, from scratch with the following content:


option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
option domain-name "example.org";
option routers 192.168.11.1;
max-lease-time 7200;

ddns-updates off;

ddns-update-style none;

log-facility local7;
default-lease-time 600;

# define rules to identify DHCP Requests from PXE and Etherboot clients.
class "pxe" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
}
class "etherboot" {
match if substring (option vendor-class-identifier, 0, 9) = "Etherboot";
}

subnet 192.168.11.0 netmask 255.255.255.0 {
range 192.168.11.51 192.168.11.60;
default-lease-time 14400;
max-lease-time 172800;
server-name "192.168.11.200";
next-server 192.168.11.200;
filename "pxelinux.0";
# allow members of "pxe";
}


Using the sample dhcpd.conf above, you can see that
  • My router IP is 192.168.11.1

  • DHCP daemon is giving out IP address starting from 192.168.11.51 to 192.168.11.60. You can adjust this setting to provide more IP addresses. The important part is to assign IP addresses outside the range of any other existing DHCP server (either in the router or in another environment where you do not have access to the official DHCP server).

  • server-name and next-server points to the IP address of the network installation server (ie pointing back to the openSUSE server that is running DHCP server, TFTP server, Apache2 server with binaries)


Alternatively, if you would like a GUI interface, you may try yast2 dhcp-server. Below are screenshots of the 4 step wizard.










3) Starting and Stopping the DHCP Server

Its best to manually start and stop the DHCP Server as required... as most LANs already have some DHCP service running... doubly so if your machine is portable (ie Laptop), you wouldn't want your Laptop to start dishing out IP addresses on boot.

To start the DHCP server, command-line (as root): rcdhcpd start

To stop the DHCP server, command-line (as root): rcdhcpd stop

No comments:

Post a Comment