1. 程式人生 > >Linux 防火牆 放開某個埠

Linux 防火牆 放開某個埠

centos7防火牆由firewalle管理,不是iptables

停止firewalld服務systemctl stop firewalld
禁用firewalld服務systemctl mask firewalld
開啟systemctl unmask firewalld

iptables操作:

安裝iptables-services:yum install iptables-services
開啟、關閉、重啟防火牆: service iptables [stop|start|restart]
或者:systemctl [stop|start|restart] iptables


永久關閉防火牆:chkconfig iptables off
永久關閉後重啟:chkconfig iptables on
設定開機啟動:systemctl enable iptables
儲存:service iptables save 或者 /usr/libexec/iptables/iptables.init save

開放某個埠

檢視防火牆開放的埠:more /etc/sysconfig/iptables
放開某個埠(如:8080)
(1)通過vim /etc/sysconfig/iptables 進入編輯增添一條 -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT


(2)執行 /etc/init.d/iptables restart 命令將iptables服務重啟