我在 CentOS 6.4 上使用 iptables 为 HTTP 打开端口 80 我通常使用 vim 编辑 /etc/sysconfig/iptables 但这次我使用 /sbin/iptables 命令。
# /sbin/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
# service iptables save
# service iptables restart
Run Code Online (Sandbox Code Playgroud)
当我列出规则时,我可以看到这样的 http:
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
Run Code Online (Sandbox Code Playgroud)
但是我无法从其他机器连接到 Web 服务器我检查了 iptables 文件,看到的内容如下:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT …
Run Code Online (Sandbox Code Playgroud) iptables ×1