ipfw revision 175686
1258057Sbr#!/bin/sh
2258057Sbr#
3258057Sbr# $FreeBSD: head/etc/rc.d/ipfw 175686 2008-01-26 14:02:19Z mtm $
4258057Sbr#
5258057Sbr
6258057Sbr# PROVIDE: ipfw
7258057Sbr# REQUIRE: ppp
8258057Sbr# BEFORE: NETWORKING
9258057Sbr# KEYWORD: nojail
10258057Sbr
11258057Sbr. /etc/rc.subr
12258057Sbr. /etc/network.subr
13258057Sbr
14258057Sbrname="ipfw"
15258057Sbrrcvar="firewall_enable"
16258057Sbrstart_cmd="ipfw_start"
17258057Sbrstop_cmd="ipfw_stop"
18258057Sbrrequired_modules="ipfw"
19258057Sbr
20266383Sianipfw_start()
21266383Sian{
22266383Sian	# set the firewall rules script if none was specified
23258057Sbr	[ -z "${firewall_script}" ] && firewall_script=/etc/rc.firewall
24258057Sbr
25258057Sbr	if [ -r "${firewall_script}" ]; then
26266331Sian		if [ -f /etc/rc.d/natd ] ; then
27266331Sian			/etc/rc.d/natd quietstart
28258057Sbr		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
49ipfw_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 quietstop
56	fi
57}
58
59load_rc_config $name
60run_rc_command "$1"
61