CentOS防火牆開啟80端口
更新CentOS防火牆設置(zhì)開啟80端(duān)口訪問
我們以(yǐ)添加80端(duān)口為例操作如下:
[root@centos httpd]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
保存
[root@centos httpd]# /etc/rc.d/init.d/iptables save
iptables:將(jiāng)防火牆規則保存到 /etc/sysconfig/iptables: [確定]
如果上麵(miàn)的步(bù)驟還沒好的話,可能是這個(gè)iptables文件(jiàn)使用的是包含調用。
一(yī)般的在/etc/sysconfig/iptables這個路徑上(shàng)
或者使用vi打開這(zhè)個文件修(xiū)改手(shǒu)動添加(jiā)
[root@centos httpd]# vi /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Tue Feb 14 07:32:18 2012
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [7:640]
-A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Tue Feb 14 07:32:18 2012
重新啟動服務
[root@centos httpd]# service iptables restart
iptables:清除防火牆(qiáng)規則: [確(què)定]
iptables:將(jiāng)鏈設置為(wéi)政策(cè) ACCEPT:filter [確定]
iptables:正在卸(xiè)載模塊: [確定(dìng)]
iptables:應用防火牆規則: [確定]
查看端口是否(fǒu)生(shēng)效:
[root@centos httpd]# /etc/init.d/iptables status
表(biǎo)格:filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:10000
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,
4 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
6 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp
7 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with ic
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with ic
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
關鍵詞:CentOS,防火牆(qiáng)
閱讀本(běn)文後(hòu)您有(yǒu)什麽感想? 已有 人(rén)給(gěi)出評價!
- 0
- 0
- 0
- 0
- 0
- 0