[Zrouter-src] ZRouter.org: push to ZRouter profiles/ipfw/files/etc/rc.d/ipfw

zrouter-src at zrouter.org zrouter-src at zrouter.org
Tue Feb 7 12:23:21 UTC 2012


details:   http://zrouter.org/hg/zrouter//rev/683b28569769
changeset: 371:683b28569769
user:      ray at terran.dlink.ua
date:      Tue Feb 07 14:22:41 2012 +0200
description:
Restore FreeBSD rc.d/ipfw script

diffstat:

 profiles/ipfw/files/etc/rc.d/ipfw |  112 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 108 insertions(+), 4 deletions(-)

diffs (118 lines):

diff -r 6c368a596e31 -r 683b28569769 profiles/ipfw/files/etc/rc.d/ipfw
--- a/profiles/ipfw/files/etc/rc.d/ipfw	Tue Feb 07 14:22:01 2012 +0200
+++ b/profiles/ipfw/files/etc/rc.d/ipfw	Tue Feb 07 14:22:41 2012 +0200
@@ -1,6 +1,110 @@
-# BEFORE: MAIN
-# PROVIDE: IPFW
+#!/bin/sh
+#
+# $FreeBSD: head/etc/rc.d/ipfw 220153 2011-03-30 01:19:00Z emaste $
+#
 
-kldload ipfw
-ipfw add 65000 allow all from any to any
+# PROVIDE: ipfw
+# REQUIRE: ppp
+# KEYWORD: nojail
 
+. /etc/rc.subr
+. /etc/network.subr
+
+name="ipfw"
+rcvar="firewall_enable"
+start_cmd="ipfw_start"
+start_precmd="ipfw_prestart"
+start_postcmd="ipfw_poststart"
+stop_cmd="ipfw_stop"
+required_modules="ipfw"
+
+set_rcvar_obsolete ipv6_firewall_enable
+
+ipfw_prestart()
+{
+	if checkyesno dummynet_enable; then
+		required_modules="$required_modules dummynet"
+	fi
+
+	if checkyesno firewall_nat_enable; then
+		if ! checkyesno natd_enable; then
+			required_modules="$required_modules ipfw_nat"
+		fi
+	fi
+}
+
+ipfw_start()
+{
+	local   _firewall_type
+
+	_firewall_type=$1
+
+	# set the firewall rules script if none was specified
+	[ -z "${firewall_script}" ] && firewall_script=/etc/rc.firewall
+
+	if [ -r "${firewall_script}" ]; then
+		/bin/sh "${firewall_script}" "${_firewall_type}"
+		echo 'Firewall rules loaded.'
+	elif [ "`ipfw list 65535`" = "65535 deny ip from any to any" ]; then
+		echo 'Warning: kernel has firewall functionality, but' \
+		    ' firewall rules are not enabled.'
+		echo '           All ip services are disabled.'
+	fi
+
+	# Firewall logging
+	#
+	if checkyesno firewall_logging; then
+		echo 'Firewall logging enabled.'
+		sysctl net.inet.ip.fw.verbose=1 >/dev/null
+	fi
+}
+
+ipfw_poststart()
+{
+	local	_coscript
+
+	# Start firewall coscripts
+	#
+	for _coscript in ${firewall_coscripts} ; do
+		if [ -f "${_coscript}" ]; then
+			${_coscript} quietstart
+		fi
+	done
+
+	# Enable the firewall
+	#
+	if ! ${SYSCTL} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then
+		warn "failed to enable IPv4 firewall"
+	fi
+	if afexists inet6; then
+		if ! ${SYSCTL} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1
+		then
+			warn "failed to enable IPv6 firewall"
+		fi
+	fi
+}
+
+ipfw_stop()
+{
+	local	_coscript
+
+	# Disable the firewall
+	#
+	${SYSCTL} net.inet.ip.fw.enable=0
+	if afexists inet6; then
+		${SYSCTL} net.inet6.ip6.fw.enable=0
+	fi
+
+	# Stop firewall coscripts
+	#
+	for _coscript in `reverse_list ${firewall_coscripts}` ; do
+		if [ -f "${_coscript}" ]; then
+			${_coscript} quietstop
+		fi
+	done
+}
+
+load_rc_config $name
+firewall_coscripts="/etc/rc.d/natd ${firewall_coscripts}"
+
+run_rc_command $*


More information about the Zrouter-src mailing list