#!/bin/bash IPTABLES='/sbin/iptables' LOIF="lo0" EXTIFS="ppp0 \ eth1" INTIFS="eth0 \ usb0" /bin/echo 1 > /proc/sys/net/ipv4/ip_forward echo "Flusing old rules..." $IPTABLES -F $IPTABLES -X $IPTABLES -A INPUT -p ALL -i $LOIF -j ACCEPT $IPTABLES -A OUTPUT -p ALL -o $LOIF -j ACCEPT echo "Done" # Fix for VPN - make iptables split eth's packets (wich is 1500 bytes long) to meet ppp0's requests (1462 bytes). echo "Fixing VPN packet size" $IPTABLES -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu echo "Forwarding ICMP Fragmentation-needed" # $IPTABLES -A FORWARD -p icmp --icmp-type fragmentation-needed -j ACCEPT # $IPTABLES -A INPUT -p icmp --icmp-type fragmentation-needed -j ACCEPT # Increasing TTL echo "Increasing TTL" $IPTABLES -A PREROUTING -t mangle -i eth0 -j TTL --ttl-inc 1 #NFS stuff echo "Allowing NFS Connects" $IPTABLES -A INPUT -p tcp --dport 111 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 111 -j ACCEPT $IPTABLES -A INPUT -p tcp --dport 633 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 633 -j ACCEPT $IPTABLES -A INPUT -p tcp --dport 636 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 636 -j ACCEPT $IPTABLES -A INPUT -p tcp --dport 999 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 999 -j ACCEPT # Allowing VMWare Console $IPTABLES -A INPUT -p tcp --dport 902 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 902 -j ACCEPT # Let's allow SSH, Web and FTP server echo "Allowing SSH, WWW and FTP Servers" $IPTABLES -A INPUT --protocol tcp --dport 22 -j ACCEPT $IPTABLES -A INPUT --protocol tcp --dport 80 -j ACCEPT $IPTABLES -A INPUT --protocol tcp --dport 21 -j ACCEPT $IPTABLES -A INPUT --protocol tcp --dport 20 -j ACCEPT # We need this for torrent and games servers echo "Allowing Torrents and Games (all ports in 1024:65535)" $IPTABLES -A INPUT -p tcp --dport 1024:65535 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 1024:65535 -j ACCEPT for INTIF in `echo "${INTIFS}"` do for EXTIF in `echo "${EXTIFS}"` do echo "Enabling NAT for ${EXTIF} and ${INTIF}" $IPTABLES -t nat -A POSTROUTING -o ${EXTIF} -j MASQUERADE $IPTABLES -t nat -A POSTROUTING -o ${EXTIF} -j MASQUERADE $IPTABLES -A FORWARD -i ${INTIF} -o ${EXTIF} -m state --state NEW,ESTABLISHED -j ACCEPT done done echo "Done. Have a lot of fun"