All pastes #156754 Raw Edit

Something

public text v1 · immutable
·published 2006-09-01 00:15 UTC
rendered paste body
###eth0 is lan
###eth1 is wan
###192.168.1.1 is router IP

#!/sbin/runscript

###############################################################################
############## Firewall                                         ###############
###############################################################################

depend() {
	need net
}

start() {

ebegin "Setting up firewall ruleset"

###############################################################################
###############################################################################
############################### Initialization ################################
###############################################################################
###############################################################################
	iptables -F 		### Flush Tables
	iptables -X 		### Remove User Defined Chains
	iptables -N DEFIN 	### Define Default Input Chain (DEFIN)
###############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################

###############################################################################
###############################################################################
################################ Network Input ################################
###############################################################################
###############################################################################

	##############################################################
	################### Exceptions: System IPs ###################
	##############################################################
		iptables -A INPUT -s 192.168.1.1 -i lo -j ACCEPT
		iptables -A INPUT -s 192.168.0.0/24 -d 192.168.1.1 -i eth0 -j ACCEPT
		iptables -A INPUT -s 127.0.0.1 -i lo -j ACCEPT
	##############################################################
	##############################################################
	##############################################################

	##############################################################
	############### Exceptions: Trusted Computers ################
	##############################################################
	#iptables -A INPUT -m mac --mac-source 00:13:10:6D:8B:01 -j LIMITED 	### Linksys Router
	### Drop List ###
	#iptables -A INPUT -s #.#.#.# -j DROP
	#################
	iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
	iptables -A INPUT -j DEFIN
	#######################################################################
	########################### Rejection Rules ###########################
	#######################################################################
		iptables -A DEFIN -p tcp -j REJECT --reject-with tcp-reset
		iptables -A DEFIN -p udp -j REJECT --reject-with icmp-port-unreachable
eend $?

}

stop() {

ebegin "Clearing firewall ruleset"

iptables -F
iptables -X

eend $?
	
}