Centos 对iptables的更改无效。什么';我的剧本怎么了?
这是我在bash中运行的iptables脚本。保存配置是脚本的一部分Centos 对iptables的更改无效。什么';我的剧本怎么了?,centos,iptables,Centos,Iptables,这是我在bash中运行的iptables脚本。保存配置是脚本的一部分 #!/bin/bash # # iptables-konfigurasjon # # Set default rule to ACCEPT to avoid being locked out iptables -P INPUT ACCEPT # Flush all excisting rules iptables -F # New default rules iptables -P INPUT DROP iptab
#!/bin/bash
#
# iptables-konfigurasjon
#
# Set default rule to ACCEPT to avoid being locked out
iptables -P INPUT ACCEPT
# Flush all excisting rules
iptables -F
# New default rules
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# localhost:
iptables -A INPUT -i lo -j ACCEPT
# Not entirely shure what this is about....:
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow SSH.
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Allow http traffic for tomcat:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
# Save rules:
/sbin/service iptables save
但是,经过测试,这些规则似乎终究没有效果。
示例:如果我注释掉允许tomcat服务器通信的行,我仍然可以从外部访问我的tomcat服务器。。。。即使在重启之后
我的剧本怎么了
顺便说一句:我正在使用CentOS 6。将新添加的规则保存到您的
iptables
后,您必须重新启动服务,以便更改生效
/sbin/service iptables restart
或
您可以在脚本末尾添加以下内容(对于CentOS): iptables保存>/etc/sysconfig/iptables 服务iptables重启
/etc/rc.d/init.d/iptables restart