今天在CentOS下部署了一个Tomcat,启动没问题,但是外网不能访问,检查知防火墙开了。
1.检查防火墙是否开启,执行
/etc/init.d/iptables status
如果有下面结果,表示防火墙开启。
[[email protected] bin]# /etc/init.d/iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
2.关闭防火墙
/etc/init.d/iptables stop
然后Tomcat就能访问了。
CenOS下Tomcat外网不能访问