All pastes #606590 Raw Edit

debian gateway firewall

public shellscript v1 · immutable
·published 2007-07-06 23:11 UTC
rendered paste body
#!/bin/shPATH=/sbinWAN=eth1LAN=eth0## delete all existing rules.#iptables -Fiptables -t nat -Fiptables -t mangle -Fiptables -X#Set Default Policy#iptables -P INPUT DROP# Always accept loopback trafficiptables -A INPUT -i lo -j ACCEPT# Allow established connections, and those not coming from the outsideiptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPTiptables -A INPUT -m state --state NEW -i $LAN -j ACCEPTiptables -A FORWARD -i $WAN -o $LAN -m state --state ESTABLISHED,RELATED -j ACCEPT# Allow outgoing connections from the LAN side.iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT# Masquerade.iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE# Don't forward from the outside to the inside.# iptables -A FORWARD -i $WAN -o $LAN -j REJECT# Enable routing.echo 1 > /proc/sys/net/ipv4/ip_forward#Set Default Policy# Due to -P, not really needed now.iptables -A INPUT -j DROP### uTorrent## -- These ports are forwarded to DBRF100iptables -A PREROUTING -t nat -i $WAN -p tcp --dport 50000 -j DNAT --to 192.168.13.40:50000iptables -A INPUT -p tcp -m state --state NEW --dport 50000 -i $WAN -j ACCEPT