CentOS 7.6 防火墙打开、关闭,端口开启、关闭

 防火墙命令

#查询防火墙状态
systemctl status firewalld.service 
#打开防火墙状态          
systemctl start firewalld.service
#关闭防火墙状态            
systemctl stop firewalld.service  
#设置开机关闭防火墙           
systemctl disable firewalld.service

端口开放、关闭

#查看当前已开放端口
firewall-cmd --list-ports              
#其中 public表示[作用域] 8080/tcp 表示[端口和访问类型] --permanent[永久生效]
#其中作用域可以有:【block】、【dmz】、【drop】、【external】、【home】、【internal】、【public】、【trusted】、【work】9个种类
#开启TCP 8080端口
firewall-cmd --permanent --zone=public --add-port=8080/tcp  
#关闭TCP 8080端口    
firewall-cmd --permanent --zone=public --remove-port=8080/tcp    #关闭TCP 8080端口
#检查配置正确性
firewall-cmd --check-config 
#重新加载防火墙配置(前面的8080端口才会生效)           
firewall-cmd --reload       
# 检测8080端口是否开放
firewall-cmd --query-port=8080/tcp                         

你可能感兴趣的:(linux,centos,大数据,linux)