centos公升級到7之後,發現無法使用iptables控制linuxs的埠,google之後發現centos 7使用firewalld代替了原來的iptables。下面記錄如何使用firewalld開放linux埠:
開啟埠
firewall-cmd --zone=public --add-port=80/tcp --permanent
命令含義:
–zone #作用域
–add-port=80/tcp #新增埠,格式為:埠/通訊協議
–permanent #永久生效,沒有此引數重啟後失效
重啟防火牆
firewall-cmd --reload
檢視埠狀態
firewall-cmd --query-port=80/tcp
開啟埠範圍
systemctl start firewalld.service
firewall-cmd --add-service=ftp --permanent
firewall-cmd --add-port=8000-8888/tcp --permanent #追加被動模式的埠範圍
firewall-cmd --reload
其他命令
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl start firewalld.service
firewall-cmd --remove-port=8080/tcp --permanent
firewall-cmd --list-ports
firewall-cmd --list-service
firewall-cmd --list-all
firewall-cmd --list-all-zones
firewall-cmd --zone=public --get-service
firewall-cmd --zone=public --query-service ftp
firewall-cmd --zone=public --add-service=ftp --permanent
firewall-cmd --zone=public --remove-service=ftp --permanent
firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --remove-port=80/tcp
firewall-cmd --zone=public --add-port=8000-8888/tcp
firewall-cmd --reload
firewall-cmd --get-default-zone
firewall-cmd --get-active-zones
firewall-cmd --set-default-zone=public
firewall-cmd --panic-on
firewall-cmd --panic-off
CentOS 7 開放3306埠訪問
centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewal...
CentOS 7 開放3306埠訪問
centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewal...
CentOS 7 開放3306埠訪問
centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewal...