iptables.rules 772 B

1234567891011
  1. #!/bin/bash
  2. ifname=`cat /proc/net/dev | awk -F: 'function trim(str){sub(/^[ \t]*/,"",str); sub(/[ \t]*$/,"",str); return str } NR>2 {print trim($1)}' | grep -Ev '^lo|^sit|^stf|^gif|^dummy|^vmnet|^vir|^gre|^ipip|^ppp|^bond|^tun|^tap|^ip6gre|^ip6tnl|^teql|^ocserv' | awk 'NR==1 {print $0}'`
  3. [ -n "$ifname" ] || exit 1
  4. DIR=`dirname "$0"`
  5. TCP=`cat "${DIR}/ocserv.conf" |grep '#\?tcp-port' |cut -d"=" -f2 |sed 's/\s//g'`
  6. UDP=`cat "${DIR}/ocserv.conf" |grep '#\?udp-port' |cut -d"=" -f2 |sed 's/\s//g'`
  7. iptables -t nat -A POSTROUTING -o ${ifname} -j MASQUERADE
  8. [ -n "$TCP" ] && iptables -I INPUT -p tcp --dport ${TCP} -j ACCEPT
  9. [ -n "$UDP" ] && iptables -I INPUT -p udp --dport ${UDP} -j ACCEPT
  10. iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu