vi /etc/sysconfig/iptables
-a input -m state –state new
-m tcp -p tcp –dport 80
-j accept(允許80埠通過防火牆)
-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 80 -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
/etc/init.d/iptables restart
#最後重啟防火牆使配置生效
若要關閉某個埠,則可以:
-a input -m state –state new
-m tcp -p tcp –dport 3306
-j drop
Linux防火牆關閉開啟
今日在linux測試環境上裝了乙個tomcat,在windows本機上訪問無果 在linux 192.168.10.97 機器上,執行wget 能夠正常獲取資料。於是斷定是防火牆開啟了。於是查詢linux防火牆關閉的方法 檢視防火牆狀態 chkconfig iptables list 1 重啟後生效...
關閉或開啟Linux上的防火牆
關閉 etc rc.d init.d iptables stop 開啟 etc rc.d init.d iptables start 檢視當前配置 iptables l redhat chkconfig level 2345 iptables off service iptables stop 但是...
關閉或開啟Linux上的防火牆
關閉 etc rc.d init.d iptables stop 開啟 etc rc.d init.d iptables start 檢視當前配置 iptables l redhat chkconfig level 2345 iptables off service iptables stop 但是...