Skip to content

Instantly share code, notes, and snippets.

@SanCoder-Q
Created November 13, 2017 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SanCoder-Q/3ad3a1a153ec836ae308ddca1d8227ff to your computer and use it in GitHub Desktop.
Save SanCoder-Q/3ad3a1a153ec836ae308ddca1d8227ff to your computer and use it in GitHub Desktop.
#清空所有链
iptables --flush
iptables --delete-chain
iptables --table mangle --flush
iptables --table mangle --delete-chain
#设定默认规则
iptables --policy INPUT DROP
iptables --policy OUTPUT ACCEPT
iptables --policy FORWARD DROP
#允许SSH
iptables --append INPUT --protocol tcp --dport 22-j ACCEPT
#允许Shadowsocks端口
iptables --append INPUT --protocol tcp --dport 8888 -j ACCEPT
#允许合法接入链接
iptables --append INPUT --match conntrack --ctstate ESTABLISHED,RELATED --jump ACCEPT
#永久化
iptables-save > /etc/iptables_rules
echo "/sbin/iptables-restore < /etc/iptables_rules" >> /etc/rc.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment