Linux firewall ports

When using some software on the server, you need to open the corresponding firewall port number. A simple understanding of Linux firewall ports

Firewall policy
Firewall policy can be customized based on information such as source and destination addresses, port numbers, protocols, and applications of traffic. Then the firewall uses pre-customized policy rules to monitor incoming and outgoing traffic. If the traffic matches a policy rule, the corresponding policy rule is executed. processed, otherwise discarded. Play a filtering role to ensure the security of the host.

View firewall service status

systemctl status firewalld

insert image description here

Start, restart, shut down, firewalld.service service

1. Turn on

service firewalld start

2. Reboot

service firewalld restart

3. Close

service firewalld stop

4. View firewall rules

firewall-cmd --list-all    # 查看全部信息
firewall-cmd --list-ports  # 只看端口信息

insert image description here

5. Open the port

开端口命令:firewall-cmd --zone=public --add-port=8080/tcp --permanent
重启防火墙服务:systemctl restart firewalld.service

Command meaning:

--zone #作用域
--add-port=80/tcp  #添加端口,格式为:端口/通讯协议
--permanent   #永久生效,没有此参数重启后失效

For example: open port 6380 protocol bit tcp permanent effective scope is all

firewall-cmd --zone=public --add-port=6380/tcp --permanent

insert image description here
Open successfully!
insert image description here

Note: If you use the Xshell remote connection to open the firewall port, you also need to add the corresponding port rule to the firewall in the security of the Alibaba Cloud server
insert image description here

Guess you like

Origin blog.csdn.net/qq_52595134/article/details/123070371