]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/ipfw
This commit was generated by cvs2svn to compensate for changes in r171831,
[FreeBSD/FreeBSD.git] / etc / rc.d / ipfw
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: ipfw
7 # REQUIRE: ppp
8 # BEFORE: NETWORKING
9 # KEYWORD: nojail
10
11 . /etc/rc.subr
12 . /etc/network.subr
13
14 name="ipfw"
15 rcvar="firewall_enable"
16 start_cmd="ipfw_start"
17 stop_cmd="ipfw_stop"
18 required_modules="ipfw"
19
20 ipfw_start()
21 {
22         # set the firewall rules script if none was specified
23         [ -z "${firewall_script}" ] && firewall_script=/etc/rc.firewall
24
25         if [ -r "${firewall_script}" ]; then
26                 if [ -f /etc/rc.d/natd ] ; then
27                         /etc/rc.d/natd start
28                 fi
29                 /bin/sh "${firewall_script}"
30                 echo 'Firewall rules loaded.'
31         elif [ "`ipfw list 65535`" = "65535 deny ip from any to any" ]; then
32                 echo 'Warning: kernel has firewall functionality, but' \
33                     ' firewall rules are not enabled.'
34                 echo '           All ip services are disabled.'
35         fi
36
37         # Firewall logging
38         #
39         if checkyesno firewall_logging; then
40                 echo 'Firewall logging enabled.'
41                 sysctl net.inet.ip.fw.verbose=1 >/dev/null
42         fi
43
44         # Enable the firewall
45         #
46         ${SYSCTL_W} net.inet.ip.fw.enable=1
47 }
48
49 ipfw_stop()
50 {
51         # Disable the firewall
52         #
53         ${SYSCTL_W} net.inet.ip.fw.enable=0
54         if [ -f /etc/rc.d/natd ] ; then
55                 /etc/rc.d/natd stop
56         fi
57 }
58
59 load_rc_config $name
60 run_rc_command "$1"