Linux中防火墙Firewalld和Iptables的配置

使用外网访问项目,访问不到有可能是防火墙没有关闭,下面是控制防火墙的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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值