Links
Recent blog posts
Links
Natting/Firewall
Firewall in Linux (IPTABLES)
Sun, 05/04/2008 - 08:01 — CcRcat > /etc/rc.firewall
#!/bin/sh
# Variables
FW="/sbin/iptables"
IF1="eth0"
IF1_IP=`/sbin/ifconfig ${IF1}|grep -w inet|awk -F: '{print $2}'|awk '{print $1}'`
IF1_MASK=`/sbin/ifconfig ${IF1}|grep -w inet|awk '{print $4}'|awk -F: '{print $2}'`
IF1_NET="${IF1_IP}/${IF1_MASK}"
# Temporarily Change the Default Policy to Accept
${FW} -P INPUT ACCEPT
${FW} -P OUTPUT ACCEPT
${FW} -P FORWARD ACCEPT
# Flush and Delete Chains
${FW} -X
${FW} -F
${FW} -F -t nat
${FW} -F -t mangle
# Allow packets in/out from Loopback Device
${FW} -A INPUT -i lo -j ACCEPT