實質:防火牆策略(網絡包的出和入)管理工具html
firewall和iptables相關操做,兩者只能選擇之一。
關於二者的區別:http://www.javashuo.com/article/p-yfsclvas-db.htmllinux
防火牆概述
防火牆:控制內網和外網之間的數據流通centos
一個條目爲一個規則,多個規則組合在一塊兒造成規則鏈網絡
policytcp
- ACCEPT
- REJECT(我知道你來找我,可是我拒絕;你ping我,我會應答:目的端口不可達)
- LOG(記錄)
- DROP(我知道你來了,可是我僞裝不在;你無法判斷我在不在)
chain(規則鏈)中數據處理位置工具
- INPUT
- OUTPUT
- PREROUTING
- POSTROUTING
- FORWORD
![](http://static.javashuo.com/static/loading.gif)
centos
firewall
- 狀態:firewall-cmd --state
- 啓動:systemctl start firewalld
- 中止:systemctl stop firewalld
- 重啓:systemctl restart firewalld
- 禁止開機啓動:systemctl disable firewalld
- 容許開機啓動:systemctl enable firewalld
iptables
- 查看iptables狀態:systemctl status iptables
- 啓、停、重啓:systemctl start/stop/restart iptables
- 查看已有規則:iptables -L
- 添加規則
- 直接編輯 /etc/sysconfig/iptables:-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(開放80端口),編輯後重啓
- iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT(開放22端口)
debain
firewall
- 安裝:apt-get install firewalld
- 狀態:firewall-cmd --state
- 啓動:systemctl start firewalld
- 中止:systemctl stop firewalld
- 重啓:systemctl restart firewalld
- 禁止開機啓動:systemctl disable firewalld
- 容許開機啓動:systemctl enable firewalld
iptables待續。。。
有用的博客:spa
http://www.javashuo.com/article/p-gzsdxtce-em.html.net
https://havee.me/linux/2015-01/using-firewalls-on-centos-7.htmlrest