Linux防火墙开放端口号
Linux防火墙开放端口号

centos7防火墙管理
安装防火墙
yum install firewalld systemd -y
查看已经开放的端口:
firewall-cmd --list-ports
开放端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙:
systemctl reload firewalld
报错: FirewallD is not running
解决:
(忘记截图了, 借鉴一下: https://jingyan.baidu.com/album/5552ef47f509bd518ffbc933.html?picindex=2)
① systemctl status firewalld
查看firewalld状态,发现当前是dead状态,即防火墙未开启。

② systemctl start firewalld
开启防火墙,没有任何提示即开启成功。
再次通过systemctl status firewalld查看firewalld状态,显示running即已开启了。

③ systemctl stop firewalld
如果要关闭防火墙设置,可能通过systemctl stop firewalld这条指令来关闭该功能。
CentOS中iptables防火墙 开放80端口方法
开放端口:
| 代码如下 | 复制代码 |
|
[root@WX32 ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT |
|
保存配置:
| 代码如下 | 复制代码 |
|
[root@WX32 ~]# service iptables save |
|
重启防火墙:
| 代码如下 | 复制代码 |
|
[root@WX32 ~]# service iptables restart |
|
查看配置:
| 代码如下 | 复制代码 |
|
[root@WX32 ~]# service iptables status |
|
端口查看方法:
| 代码如下 | 复制代码 |
|
[root@vcentos ~]# /etc/init.d/iptables status Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:80 2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 3 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0 Chain FORWARD (policy ACCEPT) num target prot opt source destination 1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0 |
|
补充:
查看CentOS防火墙信息:/etc/init.d/iptables status
关闭CentOS防火墙服务:/etc/init.d/iptables stop
检查是不是服务器的80端口被防火墙堵了,可以通过命令:telnet server_ip 80 来测试。
| 代码如下 | 复制代码 |
|
1>.解决方法如下: /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 2>.然后保存: /etc/rc.d/init.d/iptables save 3>.重启防火墙 /etc/init.d/iptables restart |
|
posted on 2021-03-05 16:10 stoneyeung 阅读(237) 评论(0) 收藏 举报
浙公网安备 33010602011771号