CentOS 7 opens and closes the firewall and exposes ports

CentOS 7.0 uses firewall as the firewall by default

View firewall status

firewall-cmd --state

start firewall

systemctl start firewalld.service

stop firewall

systemctl stop firewalld.service

Prohibit firewall from booting

systemctl disable firewalld.service

restart firewall

systemctl restart firewalld.service

reload configuration;

firewall-cmd –reload

To expose the port, enter the command:

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

–zone=public: Indicates that the scope is public;
–add-port=8080/tcp: Add port 8080 of the tcp protocol;
–permanent: Take effect permanently, if there is no such parameter, it can only be maintained within the current service life cycle, restart Failed after startup;

Check open ports

firewall-cmd --zone=public --list-ports

View port usage

netstat -lntp | grep 3355

Guess you like

Origin blog.csdn.net/liulihui1988/article/details/128225571