CentOS7調教firewall/iptables

來源:互聯網
上載者:User

CentOS7調教firewall/iptables

CentOS7用firewall命令“替代”了iptables。在這裡我們需要區分“iptables服務”和“iptables命令”。雖然firewalld是替代提供的防火牆管理iptables服務,但是它仍然使用iptables對核心命令動態通訊包過濾。所以它只是iptables服務代替,而不是iptables命令。

如果想使用iptables服務,執行如下命令

systemctl stop firewalld systemctl disable firewalld yum install iptables-services touch /etc/sysconfig/iptables systemctl start iptables systemctl enable iptables touch /etc/sysconfig/ip6tables systemctl start ip6tables systemctl enable ip6table

安裝firewalld和firewall-cmd請參考結尾link

檢查防火牆狀態 firewall-cmd --stat 臨時開放ftp服務 firewall-cmd --add-service=ftp 永久開放ftp服務 firewall-cmd --add-service=ftp --permanent 關閉ftp服務 firewall-cmd --remove-service=ftp --permanent 配置防火牆在public地區永久開放http服務 firewall-cmd --permanent --zone=public --add-service=http 加入指定開放連接埠 firewall-cmd --add-port=1324/tcp 為了讓之前的設定生效當然要重啟服務咯 systemctl restart firewalld 或者使用下面的命令免去重啟服務(防火牆策略配置後重新載入) firewall-cmd --complete-reload firewall-cmd --reload (這兩句功能相同) 檢查ftp服務的21連接埠是否開放 iptables -L -n | grep 21 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:21 ctstate NEW 查詢ftp服務啟用狀態 firewall-cmd --query-service ftp 查看當前規則 firewall-cmd --list-all 僅允許部分IP訪問本機服務配置 firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" \ source address="192.168.0.4/24" service name="http" accept" 僅允許部分IP訪問本機連接埠配置 firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" \ source address="192.168.0.4/24" \ port protocol="tcp" port="8080" accept"

公用設定檔位置:/etc/firewalld/zones/public.xml

更多內容:http://oracle-base.com/articles/linux/linux-firewall-firewalld.php?utm_source=tuicool

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.