首先可以查看有哪些端口是开放状态:
netstat -ntpl
Centos 7.0 之前的版本,防火墙用的是 iptables,7.0 之后使用 firewalld 代替了 iptables,那么我们来分别看看这两种防火墙的命令操作:
1. 查看防火墙状态
systemctl status firewalld
service iptables status
2. 暂时关闭防火墙
systemctl stop firewalld
service iptables stop
3. 永久关闭防火墙
systemctl disable firewalld
chkconfig iptables off
4. 重启防火墙
systemctl enable firewalld
service iptables restart
5. 开放指定端口
编辑文件: vi /etc/sysconfig/iptables
添加开放端口:iptables -I INPUT -p tcp –dport 端口号 -j ACCEPT
保存配置:service iptables save
重启防火墙:service iptables restart
1. 查看防火墙状态
systemctl status firewalld
firewall-cmd –state
2. 启动防火墙
systemctl start firewalld
3.禁用防火墙
systemctl stop firewalld
4.设置开机启动
systemctl enable firewalld
5.停止并禁用开机启动
sytemctl disable firewalld
6.重启防火墙
systemctl restart firewalld.service
firewall-cmd –reload
7. 开放指定端口
添加端口: firewall-cmd –zone=public –add-port=端口号/tcp –permanent
重启防火墙:systemctl restart firewalld.service
以上就是我服了网»linux防火墙开放端口命令给指定ip(CentOS Linux 防火墙添加端口开放)的相关内容了,更多精彩请关注我服了号公众号。
声明:本文由猫小编【创业者资源平台】作者编辑发布,更多技术关注猫小编技术!