Linux配置防火牆的相關命令

2021-08-13 03:23:14 字數 1176 閱讀 5196

(命令直接複製執行!)

檢視防火牆狀態:

/etc/init.d/iptables status

暫時關閉防火牆:

/etc/init.d/iptables stop

配置防火牆:

vi /etc/sysconfig/iptables

-a input -m state –state new -m tcp -p tcp –dport 8080 -j accept(允許8080埠通過防火牆)

-a input -m state –state new -m tcp -p tcp –dport 3306 -j accept(允許3306埠通過防火牆)

新增好之後防火牆配置如下所示:

# firewall configuration written by system-config-firewall 

# manual customization of this file is not recommended.

*filter

:input accept [0:0]

:forward accept [0:0]

:output accept [0:0]

-ainput -m state –state established,related -j accept

-ainput -p icmp -j accept

-ainput -i lo -j accept

-ainput -m state –state new -m tcp -p tcp –dport 22 -j accept

-ainput -m state –state new -m tcp -p tcp –dport 8080 -j accept

-ainput -m state –state new -m tcp -p tcp –dport 3306 -j accept

-ainput -j reject –reject-with icmp-host-prohibited

-aforward -j reject –reject-with icmp-host-prohibited

commit

注意:新增的埠要放在22埠規則後面。

重啟防火牆使配置生效:

/etc/init.d/iptables restart

linux防火牆相關命令

一 防火牆相關命令 1 檢視防火牆狀態 systemctl status firewalld.service 注 active是綠的running表示防火牆開啟 2 關閉防火牆 systemctl stop firewalld.service 3 開機禁用防火牆自啟命令 systemctl disa...

防火牆相關命令

firewall cmd zone public add port 6379 tcp permanent firewall cmd zone public add port 80 tcp permanent 那怎麼開啟乙個埠呢 新增firewall cmd zone public add port ...

linux防火牆相關

linux 防火牆 selinux設定 sestatus v 檢視selinux執行狀態 semanage fcontext a t httpd sys content t home deploy share portal 設定目錄許可權 nginx403錯誤 restorecon rv home ...