]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/system/dhcp
suricata: Change midstream policy to "pass-flow"
[ipfire-2.x.git] / src / initscripts / system / dhcp
CommitLineData
6bdd769d 1#!/bin/sh
66c36198
PM
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
6bdd769d
MT
21
22. /etc/sysconfig/rc
23. $rc_functions
6f5d8f0c 24
0eccedd1
MT
25[ -e "/etc/sysconfig/dhcpd" ] && . /etc/sysconfig/dhcpd
26
6bdd769d 27eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
6f5d8f0c 28eval $(/usr/local/bin/readhash /var/ipfire/dhcp/settings)
6bdd769d 29
8490e496
MT
30function flush_chains() {
31 iptables -F DHCPGREENINPUT
32 iptables -F DHCPGREENOUTPUT
33 iptables -F DHCPBLUEINPUT
34 iptables -F DHCPBLUEOUTPUT
35}
36
6bdd769d
MT
37case "$1" in
38 start)
8490e496
MT
39 flush_chains
40
838925a6 41 if [ -n "${GREEN_DEV}" -a -e "/var/ipfire/dhcp/enable_green" ]; then
0eccedd1 42 LISTEN_INTERFACES+=" ${GREEN_DEV}"
8490e496
MT
43
44 iptables -A DHCPGREENINPUT -i "${GREEN_DEV}" -j DHCPINPUT
45 iptables -A DHCPGREENOUTPUT -o "${GREEN_DEV}" -j DHCPOUTPUT
6bdd769d 46 fi
838925a6 47 if [ -n "${BLUE_DEV}" -a -e "/var/ipfire/dhcp/enable_blue" ]; then
0eccedd1 48 LISTEN_INTERFACES+=" ${BLUE_DEV}"
8490e496
MT
49
50 iptables -A DHCPBLUEINPUT -i "${BLUE_DEV}" -j DHCPINPUT
51 iptables -A DHCPBLUEOUTPUT -o "${BLUE_DEV}" -j DHCPOUTPUT
52 fi
53
6bdd769d 54 boot_mesg "Starting DHCP Server..."
0eccedd1 55 loadproc /usr/sbin/dhcpd -q ${LISTEN_INTERFACES}
838925a6 56
6f5d8f0c
MT
57 # Start Unbound DHCP Lease Bridge unless RFC2136 is used
58 if [ "${DNS_UPDATE_ENABLED}" != on ]; then
59 boot_mesg "Starting Unbound DHCP Leases Bridge..."
60 loadproc /usr/sbin/unbound-dhcp-leases-bridge -d
61 fi
62
a2d5130f 63 (sleep 5 && chmod 644 /var/run/dhcpd.pid) & # Fix because silly dhcpd creates its pid with mode 640
6bdd769d
MT
64 ;;
65
66 stop)
8490e496
MT
67 flush_chains
68
6bdd769d 69 boot_mesg "Stopping DHCP Server..."
e5ba3160 70 killproc -p /var/run/dhcpd.pid /usr/sbin/dhcpd
274a6064
AF
71 if [ "$(ps -A | grep " dhcpd")" != "" ] ; then
72 # if fail use the hard way ...
73 boot_mesg "Killing DHCP Server..."
74 killall -w -s KILL /usr/sbin/dhcpd > /dev/null 2>&1
75 rm -f /var/run/dhcpd.pid > /dev/null 2>&1
76 echo_ok;
274a6064 77 fi
6f5d8f0c
MT
78
79 boot_mesg "Stopping Unbound DHCP Leases Bridge..."
80 killproc /usr/sbin/unbound-dhcp-leases-bridge
6bdd769d
MT
81 ;;
82
83 reload)
84 boot_mesg "Reloading DHCP Server..."
85 reloadproc /usr/sbin/dhcpd
86 ;;
87
88 restart)
89 $0 stop
90 sleep 1
91 $0 start
92 ;;
93
94 status)
95 statusproc /usr/sbin/dhcpd
6f5d8f0c 96 statusproc /usr/sbin/unbound-dhcp-leases-bridge
6bdd769d
MT
97 ;;
98
99 *)
100 echo "Usage: $0 {start|stop|reload|restart|status}"
101 exit 1
102 ;;
103esac