首先可以查看有哪些端口是開放狀態:
netstat -ntpl
Centos 7.0 之前的版本,防火牆用的是 iptables,7.0 之後使用 firewalld 代替了 iptables,那麼我們來分別看看這兩種防火牆的命令操作:
iptables
1. 查看防火牆狀態
systemctl status firewalld
service iptables status
2. 暫時關閉防火牆
systemctl stop firewalld
service iptables stop
3. 永久關閉防火牆
systemctl disable firewalld
chkconfig iptables off
4. 重啟防火牆
systemctl enable firewalld
service iptables restart
5. 開放指定端口
編輯文件: vi /etc/sysconfig/iptables
添加開放端口:iptables -I INPUT -p tcp –dport 端口號 -j ACCEPT
保存配置:service iptables save
重啟防火牆:service iptables restart
firewalld
1. 查看防火牆狀態
systemctl status firewalld
firewall-cmd –state
2. 啟動防火牆
systemctl start firewalld
3.禁用防火牆
systemctl stop firewalld
4.設置開機啟動
systemctl enable firewalld
5.停止並禁用開機啟動
sytemctl disable firewalld
6.重啟防火牆
systemctl restart firewalld.service
firewall-cmd –reload
7. 開放指定端口
添加端口: firewall-cmd –zone=public –add-port=端口號/tcp –permanent
重啟防火牆:systemctl restart firewalld.service
原創文章,作者:投稿專員,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/274560.html
微信掃一掃
支付寶掃一掃