Skip to content

Instantly share code, notes, and snippets.

@lajunta
Created November 8, 2010 09:47
Show Gist options
  • Save lajunta/667527 to your computer and use it in GitHub Desktop.
Save lajunta/667527 to your computer and use it in GitHub Desktop.
simple firewall for 22 53 80
iptables -F
# 允许包从22端口进入
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# 允许从22端口进入的包返回
iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --sport 53 -j ACCEPT
#允许本机访问本机
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
#允许所有IP访问80端口
iptables -A INPUT -p tcp -s 0/0 --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
#保存配置
iptables-save > /etc/sysconfig/iptables
iptables -L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment