How to install dhcp, dns, pxe on debian squeeze


This document describes how to install DHCP, DNS and PXE network services on a debian squeeze.

For this tutorial I use a machine that has two network interfaces:
eth0: (WAN interface)
eth1: (LAN interface)

To install a PXE server, you will need the following components:
DHCP Server
TFTP Server
NFS/FTP/HTTPD server (to store installing files)

Note: DHCP Server will listen only on eth1.
         In this tutorial I will use apache2 server.

Install required packages

apt-get install tftpd-hpa syslinux dhcp3-server bind9 dnsutils

Configure DHCP Server

vim /etc/dhcp/dhcpd.conf

ddns-update-style ad-hoc;
log-facility syslog;

option domain-name "";
option domain-name-servers;
option subnet-mask;
subnet netmask {
    range; # ip range
    option routers; # gateway for clients
    # in case want to deny clients that are not configured in dhcpd uncomment the following line
    #deny unknown-clients;
    allow booting;
    allow bootp;
    next-server; # tftpd server's IP
    filename "pxelinux.0";

    # sample of a client that has mac address reserved on dhcp
    #host guest1 {
    #    hardware ethernet 00:0C:29:14:DA:AD;
    #    fixed-address;

Force DHCP Server to listen only on eth1

vim /etc/default/isc-dhcp-server

Configure TFTP Server. Change the root directory on startup from /srv/tftp to /tftpboot

vim /etc/default/tftpd-hpa

Setup TFTP Server network boot files

mkdir -p /tftpboot
chmod 777 /tftpboot
cp -v /usr/lib/syslinux/pxelinux.0 /tftpboot
cp -v /usr/lib/syslinux/menu.c32 /tftpboot
cp -v /usr/lib/syslinux/memdisk /tftpboot
cp -v /usr/lib/syslinux/mboot.c32 /tftpboot
cp -v /usr/lib/syslinux/chain.c32 /tftpboot
mkdir /tftpboot/pxelinux.cfg

Create PXE menu file

vim /tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
timeout 300

LABEL centos6.3_i386
    MENU LABEL CentOS 6.3 i386
    KERNEL /netboot/centos/6.3/i386/vmlinuz
    APPEND console=tty0 console=ttyS0,9600N1 initrd=/netboot/centos/6.3/i386/initrd.img ks=  ksdevice=link

Share the internet connection with clients

vim /etc/sysctl.conf

Apply the settings:

sysctl -p

Share internet connection using iptables:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Configure bind9

echo "include \"/etc/bind/bind.keys\"; ">> /etc/bind/named.conf
vim /etc/bind/named.conf.options

options {
        directory "/var/cache/bind";
        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { none; };
        forwarders {;; };
        listen-on port 53 { any; };
        allow-query { any; };
        allow-query-cache { any; };

Add the following lines at the end of the named.conf.default-zones

vim /etc/bind/named.conf.default-zones

zone "" {
        type master;
        file "/etc/bind/";

zone "" {
        type master;
        file "/etc/bind/";

vim /etc/bind/


$TTL 1H          IN SOA (
                                2012062600      ; serial
                                12H             ; refresh
                                2H              ; retry
                                1W              ; expiry
                                2D )            ; minimum      IN    NS   IN    A

www10          IN    A
www11          IN    A
www12          IN    A
www13          IN    A
www14          IN    A
www15          IN    A

vim /etc/bind/



@          IN SOA (
                                2012062600      ; serial
                                12H             ; refresh
                                2H              ; retry
                                1W              ; expiry
                                2D )            ; minimum

@     IN    NS

1     IN    PTR

10    IN    PTR
11    IN    PTR
12    IN    PTR
13    IN    PTR
14    IN    PTR
15    IN    PTR

Let's use our DNS server

echo "search" > /etc/resolv.conf
echo "nameserver" >> /etc/resolv.conf

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.