使用外网访问项目,访问不到有可能是防火墙没有关闭,下面是控制防火墙的linux命令
1.查 看 防 火 墙 的 状 态 ( 是 否 开 启 了 防 火 墙 )
systemctl status firewalld
service iptables status
2.暂 时 关 闭 防 火 墙 ( 如 果 防 火 墙 默 认 是 开 启 的 , 重 启 服 务 器 之 后 防 火 墙 默 认 开 启 )
systemctl stop firewalld
service iptables stop
3.永 久 关 闭 防 火 墙 ( 重 启 服 务 器 , 防 火 墙 也 是 关 闭 的 )
systemctl disable firewalld
chkconfig iptables off
4.暂 时 开 启 防 火 墙 ( 如 果 防 火 墙 默 认 是 关 闭 的 , 重 启 服 务 器 之 后 防 火 墙 默 认 关 闭 )
systemctl start firewalld
service iptables start
5.永 久 开 启 防 火 墙 ( 重 启 服 务 器 , 防 火 墙 也 是 开 启 的 )
systemctl enable firewalld
chkconfig iptables on
6.重启防火墙
service iptables restart (iptable开启防火墙或者关闭之后,需重新启动防火墙,firewalld则不需要)
7.不 关 闭 防 火 指 定 一 个 端 口 外 网 访 问 ( 以 8080 端 口 为 例 )
firewall-cmd --zone=public --add-port=8080/tcp --permanent (--permanent参数为永久生效,如果不加,重启服务器之后将失效)
8.永 久 关 闭 端 口 ( 以 8080 端 口 为 例 )
firewall-cmd --zone= public --remove-port=8080/tcp --permanent