2 # Begin $rc_base/init.d/dhcp
4 # Based on sysklogd script from LFS-3.1 and earlier.
5 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
6 # Modified for IPFire by Michael Tremer - mitch@ipfire.org
11 [ -e "/etc/sysconfig/dhcpd" ] && .
/etc
/sysconfig
/dhcpd
13 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
14 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/dhcp
/settings
)
16 function flush_chains
() {
17 iptables
-F DHCPGREENINPUT
18 iptables
-F DHCPGREENOUTPUT
19 iptables
-F DHCPBLUEINPUT
20 iptables
-F DHCPBLUEOUTPUT
27 if [ -n "${GREEN_DEV}" -a -e "/var/ipfire/dhcp/enable_green" ]; then
28 LISTEN_INTERFACES
+=" ${GREEN_DEV}"
30 iptables
-A DHCPGREENINPUT
-i "${GREEN_DEV}" -j DHCPINPUT
31 iptables
-A DHCPGREENOUTPUT
-o "${GREEN_DEV}" -j DHCPOUTPUT
33 if [ -n "${BLUE_DEV}" -a -e "/var/ipfire/dhcp/enable_blue" ]; then
34 LISTEN_INTERFACES
+=" ${BLUE_DEV}"
36 iptables
-A DHCPBLUEINPUT
-i "${BLUE_DEV}" -j DHCPINPUT
37 iptables
-A DHCPBLUEOUTPUT
-o "${BLUE_DEV}" -j DHCPOUTPUT
40 boot_mesg
"Starting DHCP Server..."
41 loadproc
/usr
/sbin
/dhcpd
-q ${LISTEN_INTERFACES}
43 # Start Unbound DHCP Lease Bridge unless RFC2136 is used
44 if [ "${DNS_UPDATE_ENABLED}" != on
]; then
45 boot_mesg
"Starting Unbound DHCP Leases Bridge..."
46 loadproc
/usr
/sbin
/unbound-dhcp-leases-bridge
-d
49 (sleep 5 && chmod 644 /var
/run
/dhcpd.pid
) & # Fix because silly dhcpd creates its pid with mode 640
55 boot_mesg
"Stopping DHCP Server..."
56 killproc
-p /var
/run
/dhcpd.pid
/usr
/sbin
/dhcpd
57 if [ "$(ps -A | grep " dhcpd
")" != "" ] ; then
58 # if fail use the hard way ...
59 boot_mesg
"Killing DHCP Server..."
60 killall
-w -s KILL
/usr
/sbin
/dhcpd
> /dev
/null
2>&1
61 rm -f /var
/run
/dhcpd.pid
> /dev
/null
2>&1
65 boot_mesg
"Stopping Unbound DHCP Leases Bridge..."
66 killproc
/usr
/sbin
/unbound-dhcp-leases-bridge
70 boot_mesg
"Reloading DHCP Server..."
71 reloadproc
/usr
/sbin
/dhcpd
81 statusproc
/usr
/sbin
/dhcpd
82 statusproc
/usr
/sbin
/unbound-dhcp-leases-bridge
86 echo "Usage: $0 {start|stop|reload|restart|status}"
91 # End $rc_base/init.d/dhcp