Skip to content

Instantly share code, notes, and snippets.

@themasch
Created February 24, 2015 17:10
Show Gist options
  • Save themasch/ed9742ac967e3cf65f6b to your computer and use it in GitHub Desktop.
Save themasch/ed9742ac967e3cf65f6b to your computer and use it in GitHub Desktop.
iptables.sh
IPT=$(which iptables)
#IPT=echo
LAN=("eth1" "eth2" "wlan0")
WAN="eth0"
$IPT -F
$IPT -t nat -F
$IPT -P INPUT ACCEPT
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD DROP
$IPT -I INPUT 1 -i lo -j ACCEPT
for IF in ${LAN[@]}
do
$IPT -I INPUT 1 -i ${IF} -j ACCEPT
$IPT -A INPUT -p UDP --dport bootps ! -i ${IF} -j REJECT
$IPT -A INPUT -p UDP --dport domain ! -i ${IF} -j REJECT
$IPT -I FORWARD -i ${IF} -d 10.13.37.0/255.255.255.0 -j DROP
$IPT -A FORWARD -i ${IF} -s 10.13.37.0/255.255.255.0 -j ACCEPT
done
$IPT -A FORWARD -i ${WAN} -d 10.13.37.0/255.255.255.0 -j ACCEPT
$IPT -t nat -A POSTROUTING -o ${WAN} -j MASQUERAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment