Check the CentOS version, system bit number and settings CentOS 7.9 2009 firewall configuration to open the port command and process

1. Check the CentOS version and system digits

1.1 Command summary

//1、安装redhat-lsb
yum install -y redhat-lsb

//2、查看系统版本信息
lsb_release -a 

//3、查看系统位数
getconf LONG_BIT

1.2 Screenshots

Insert image description here
Insert image description here
Insert image description here

2. Set up CentOS7.9 2009 firewall configuration to open ports

2.1 Command summary


//禁止防火墙开机启动。这种方法方便,但不安全。
systemctl disable firewalld

下面  设置CentOS7.9 2009 防火墙配置放开端口8083

//1-防火墙设置开机自启
systemctl enable firewalld

//2-查询防火墙状态
systemctl status firewalld

//3-启动防火墙
systemctl start firewalld

//4-查询防火墙状态,确保已经启动active(running)
systemctl status firewalld

//5-查看防火墙是否放行nginx8083端口 no:代表没开8083端口,yes表示已开nginx8083端口。
firewall-cmd --query-port=8083/tcp

//6-设置永久放行Nginx8083端口,”–permanent“参数表示,永久生效,没有此参数重启后失效,表示重启后8083端口无法通过。
firewall-cmd --add-port=8083/tcp --permanent

//7-【设置永久放行Nginx8083端口,重启防火墙后才能查询到防火墙已经放行Nginx8083端口。】
//返回no,需要重启防火墙才能更新为yes
firewall-cmd --query-port=8083/tcp
//#重启防火墙
systemctl restart firewalld
//返回yes,表示永久放行Nginx8083端口
//重启防火墙后再次查看就是yes,表示8083端口已经永久放行
firewall-cmd --query-port=8083/tcp
//其他排查命令
//查看启动的nginx进程
ps -ef | grep nginx

//查看端口占用信息
//1、安装lsof
//执行lsof -i:8083命令时报错-bash: lsof: command not found,就需要安装lsof
yum install lsof

//2、查看端口占用信息
lsof -i:端口
//例如将nginx默认的80端口修改为8083端口前,查看8083端口有无被占用
lsof -i:8083
补充说明: 
zone=public:表示作用域为公共的;
add-port=8083/tcp:添加tcp协议的端口8083;
permanent:永久生效,没有此参数重启后失效,表示重启后8083端口无法通过。


//# 永久性开放端口1521
firewall-cmd --permanent --zone=public --add-port=1521/tcp
与
//6-设置永久放行Nginx8083端口,”–permanent“参数表示,永久生效,没有此参数重启后失效,表示重启后8083端口无法通过。
firewall-cmd --add-port=8083/tcp --permanent
相比,忽略端口号的不同以及参数位置不同,多了一个 zone=public:表示作用域为公共的。

2.2 Screenshots

Set up CentOS7.9 2009 firewall configuration to open port 8083 Insert image description here
to view port occupancy information
Insert image description here

Guess you like

Origin blog.csdn.net/qyfx123456/article/details/132196147