Linux iptables 防火牆狀態

Linux系統啓動防火牆

 

1) 重啓後生效

 

開啓: chkconfig iptables on

 

關閉: chkconfig iptables off

 

2) 即時生效,重啓後失效

 

開啓: service iptables start

 

關閉: service iptables stop

 

需要說明的是對於Linux下的其它服務都可以用以上命令執行開啓和關閉操作。

 

在開啓了防火牆時,做如下設置,開啓相關端口。

 

修改/etc/sysconfig/iptables 文件,添加以下內容:

 

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

 

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

 

查看所有進程,包括服務,命令裏ps -aux是netconfig在redhat裏面是字符界面下的網卡配置工具。

 

chkconfig --list;

 

查看某一個指定名字的進程:[root@szxdb /]# chkconfig --list mysql;   //查看MySQL的防火牆

 

可以列出sysV和xinet服務在各個runlevel的默認啓動狀態。

 

service 服務名 參數

 

查看狀態的參數好像是stat 吧。

 

自啓動服務

 

ntsysv

 

--------------------------------------------------------------------------------------
chkconfig命令只是查看和設置服務的自動啓動情況,並不能反映當前服務的狀態. service iptables status可以查看到iptables服務的當前狀態
但是即使服務運行了,防火牆也不一定起作用,你還得看防火牆規則的設置
iptables -L 上述命令的返回值如果顯示沒有防火牆規則,那就是不起作用;反之就是防火牆在起作用.
--------------------------------------------------------------------------------------
iptables 0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
linux有六個運行級別,0(關機),1單用戶,2多用戶(無NFS),3完全多用戶,4(未使用),5圖形界面X11,6重啓,
CENTOS/redhat,service iptables status debian,/etc/init.d/iptables
 
--------------------------------------------------------------------------------------
service iptables status 查看iptables狀態
service iptables restart iptables服務重啓
service iptables stop iptables服務禁用
發佈了7 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章