因為centos7已經開始使用firewall作為防火牆,而不是iptables
[root@localhost ~]# firewall-cmd --state
running
[root@localhost ~]# firewall-cmd --zone=public --add-port=6443/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# systemctl restart firewalld.service
[root@localhost ~]#
--zone=public:表示作用域為公共的;
--add-port=8080/tcp:新增tcp協議的埠;
--permanent:永久生效,如果沒有此引數,則只能維持當前服務生命週期內,重新啟動後失效;
載入完成埠配置可檢視
firewall-cmd --zone=public --list-ports
移除埠
firewall-cmd --zone=public --remove-port=6443/tcp --permanent
Centos7開放及檢視埠
1 開放埠 firewall cmd zone public add port 5672 tcp permanent 開放5672埠 firewall cmd zone public remove port 5672 tcp permanent 關閉5672埠 firewall cmd reload...
Centos7開放及檢視埠
1 開放埠 firewall cmd zone public add port 5672 tcp permanent 開放5672埠 firewall cmd zone public remove port 5672 tcp permanent 關閉5672埠 firewall cmd reload...
Centos7開放及檢視埠
1 開放埠 開放5672埠 firewall cmd zone public add port 5672 tcp permanent 關閉5672埠 firewall cmd zone public remove port 5672 tcp permanent 配置立即生效 firewall cmd...