歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> CentOS7中防火牆的一些常用配置,centos7防火牆配置

CentOS7中防火牆的一些常用配置,centos7防火牆配置

日期:2017/3/3 18:01:42   编辑:學習Linux

CentOS7中防火牆的一些常用配置,centos7防火牆配置

CentOS7中防火牆的一些常用配置,centos7防火牆配置



# 啟動 
systemctl start firewalld

# 查看狀態
systemctl status firewalld

# 停止關閉
systemctl disable firewalld
systemctl stop firewalld

# 把一個源地址加入白名單,以便允許來自這個源地址的所有連接
# 這個在集群中使用常見
# 設置後利用firewall-cmd --reload更新防火牆規則
firewall-cmd --add-rich-rule 'rule family="ipv4" source address="192.168.1.215" accept' --permanent
firewall-cmd --reload

# 特定域內的用戶通過ssh可以連接,24標識255.255.255.0
firewall-cmd --remove-service=ssh --permanent
firewall-cmd --add-rich-rule 'rule family=ipv4 source address=172.16.30.0/24 accept' --permanent
firewall-cmd --reload
firewall-cmd --list-all 

# 將一個用戶加入白名單
firewall-cmd --add-lockdown-whitelist-user=hadoop --permanent
firewall-cmd --reload

# 將用戶id從白名單中去掉
firewall-cmd --remove-lockdown-whitelist-uid=uid
firewall-cmd --reload

# 查看所有打開的端口:
firewall-cmd  --list-ports
# 在某個區域打開端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent

# 關閉端口
firewall-cmd --remove-port=465/tcp 

# 打開服務,參見/etc/firewalld 目錄下services文件夾中的服務,可以配置
firewall-cmd --permanent --zone=public --add-service=samba
firewall-cmd --add-service=http --permanent 
firewall-cmd --reload

# 關閉服務
firewall-cmd --zone=public --remove-service=samba
firewall-cmd --reload
 

官方文檔以及常用參考:

https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html

https://www.server-world.info/en/note?os=CentOS_7&p=firewalld

http://xxxxxx/Linuxjc/1177405.html TechArticle

Copyright © Linux教程網 All Rights Reserved