iptables

iptables

下面列出一段比较通用的服务器 iptable 设置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 允许回环地址
iptables -A INPUT -i lo -j ACCEPT
# 允许已建立的连接
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# 允许自定义的端口进行 TCP 通讯,按需要增减
iptables -A INPUT -p tcp -m multiport --dports 22,443,8388:8400 -j ACCEPT
# 允许自定义的端口进行 UDP 通讯,按需要增减
# iptables -A INPUT -p udp -m multiport --dports 53 -j ACCEPT
# 允许 ping 包
iptables -A INPUT -p icmp -j ACCEPT
# 其余都禁止
iptables -A INPUT -j DROP

附一份比较通俗易懂的 iptables 介绍文档。 ( http://www.zsythink.net/archives/tag/iptables/ )