Centos 7 firewall and port settings

CentOS 7 firewall and port settings

Firewall management

# Start firewall systemctl start firewalld# Turn off the firewall systemctl stop firewalld# Restart the firewall systemctl restart firewalld # Set the startup firewall systemctl enable firewalld# Set the startup firewall not to start systemctl disable firewalld

Port Management

# Open port# --zone range# --add-port=80/tcp Add port, the format is: port/communication protocol# --permanent permanent effective, no This parameter becomes invalid after restarting# Single port firewall-cmd --zone=public --add-port=80/tcp --permanent#Multiple ports: firewall-cmd --zone=public --add-port=80-90 /tcp --permanent# View the listening ports that have been enabled on this machine ss -ant# View all information about the firewall firewall-cmd --list-all# View all ports opened by the firewall firewall-cmd --list-ports# Close a port firewall -cmd --zone=public --remove-port=80/tcp --permanent# The firewall configuration takes effect immediately firewall-cmd --reload# Check which process the port is occupied by netstat -lnpt |grep port number# View the detailed information of the process ps PID# abort the process kill -9 PID

Leave a Comment

Your email address will not be published.