Installing dhcpd on your LAN interface under Red Hat 7.3

Sins committed in Dec 2002, but Jan K. Labanowski,
Disclaimer: all stuff below is a nonsense, and you cannot rely on any of this. Only laywers can tell you how to install your software reliably, or how to sue someone for giving you the wrong advice. The advice below is wrong, and you should not use it, and you cannot sue me either, since you have been warned that this is nonsense. You can also post it wherever you want, provided that you include this notice, or remove any trace of my identity from this memo. -- Jan Labanowski, Please send corrections to me at and be lenient on me if I do not answer -- I am kind of busy lately.

You may often prefer to have an option that your firewall acts also as DHCP server, i.e., it assigns a dynamic, temporary IP address to a computer when it requests it, e.g., when it boots. Note that static and dynamic IP addresses can coexists safely on the LAN. You need to specify the range of addresses to be used for static addressing, and select a range of addresses to be used for dynamic assignment. In my case, I use static addresses for the desktop computers (which do not move), and the dynamic addresses for the laptops. Static addresses have the advantage since you can assign some services to them (e.g., print server, NFS server, etc) and they will not change their IP addresses. However, when your computer is a client by definition (e.g., a laptop which you carry to work, to hotels, and then bring home), the DHCP is very handy.

Installing dhcpd

To do this, you need to install dhcp (namely, dhcpd -- DHCP daemon). DO not confuse this with a dhcpcd (DHCP client daemon). The DHCP is the server which provides the IP addresses for computers which request it. The DHCP Client daemon is the program running on the computer which requests the address, and renews/maintains it.

I used the RPM package: dhcp-2.0pl5-8.i386.rpm which is available on the 2nd CD in RH 7.3 distribution under RedHat/RPMS. You can also get it from the net, e.g.:
Being a root, I unpacked it as:

rpm -Uhv dhcp-2.0pl5-8.i386.rpm
By default it will come inactive on boot. You need to add a few things.


The /etc/dhcpd.conf file:

subnet netmask { 
        option subnet-mask; 
        option broadcast-address; 
        option routers; 
        option domain-name-servers,; 
        option domain-name "mylan"; 

This assumes that you will be returning addresses for the "nonroutable"
subnet: Only addresses in the range from
to will be served. This way you can use addresses in the
range: to for your computers with static assigned 
addresses. The routers option relates to the IP address of your
router interface (in my case eth1) which is connected to the internal
LAN. In my case, it has the IP address: The domain-name-servers
is a VERY IMPORTANT ENTRY. It is intentionally BOGUS in the above
example (note that digits are larger than 7 in the example above).
You take these numbers from the file: /etc/resolv.conf on
your firewall. Those are usually assigned by your Internet Service 
Provider. You can also run your own DNS server, and then you give
its address here (e.g., if you ran it on the firewall [bad idea], than
it would be Domain name in the above example is what you
want to assigne to your internal network internally. It does not matter
for the world outside, since they only see your firewall, and the
name/address assigned to it.


The /etc/sysconfig/dhcpdf contains parameters to be entered on the command line of dhcpd when it is started. In my case, I only give there the interface name on which I want DHCP to run. In my case, my LAN is attached to the eth1 interface of my firewal, so this is where it need to be:

# Command line options here 


The script which starts the DHCP server on boot-up is located in /etc/rc.d/init.d/dhcpd with other startup scripts of RH7.3 linux. You do not need to edit the script, and look for the line:
# chkconfig: - 65 35
or something similar. Change it to:
# chkconfig: 345 65 35
The boot-up links for DHCP are usually inactive, so you need to add them. What I did is:
cd /etc/rc.d
find . -name "[SK]*dhcpd" -exec rm {} \;       # this deletes old links
cd init.d
chkconfig --add dhcpd
chkconfig --list dhcpd
You should see "on" at runlevels: 3, 4, and 5.

Your firewall script

By default, the firewall will usually block the broadcasts and will not allow your LAN computers to query the DHCP for address. You need to put something like this close to the top of your firewall script, to allow for the DHCP to serve your LAN

$IPTABLES -t nat -A PREROUTING -i eth1 -p UDP -s \
       --sport 68 --dport 67 -j ACCEPT

$IPTABLES -A OUTPUT -o eth1 -p UDP -s --sport 67  \
       -d --dport 68 -m state --state ESTABLISHED -j ACCEPT

$IPTABLES -A INPUT  -i eth1 -p UDP -s --sport 68 \
      -d --dport 67 -m state --state NEW,ESTABLISHED \
      -j ACCEPT

$IPTABLES -A OUTPUT -o eth1 -p UDP -s any/0--sport 67 -d \
      --dport 68 -m state --state ESTABLISHED -j ACCEPT

$IPTABLES -A INPUT  -i eth1 -p UDP -s --sport 68 
     -d any/0 --dport 67 -m state --state NEW,ESTABLISHED -j ACCEPT


   $IPTABLES -A OUTPUT -o eth1 -p tcp -s --sport 67 -d --dport 68 -j ACCEPT
        $IPTABLES -A OUTPUT -o $internal_int -p udp -s $internal_ip --sport 67 -d --dport 68 -j ACCEPT
        $IPTABLES -A INPUT -i $internal_int -p tcp --sport 68 --dport 67 -j ACC\EPT
   $IPTABLES -A INPUT -i $internal_int -p udp --sport 68 --dport 67 -j ACCEPT