ipfw revision 165683
1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/ipfw 165683 2006-12-31 10:37:18Z yar $
4#
5
6# PROVIDE: ipfw
7# REQUIRE: ppp
8# BEFORE: NETWORKING
9# KEYWORD: nojail
10
11. /etc/rc.subr
12. /etc/network.subr
13
14name="ipfw"
15rcvar="firewall_enable"
16start_cmd="ipfw_start"
17stop_cmd="ipfw_stop"
18required_modules="ipfw"
19
20ipfw_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		. "${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 stop
56	fi
57}
58
59load_rc_config $name
60run_rc_command "$1"
61