CentOS 6.x & Fedora17 開啟8080埠給遠端電腦訪問:防火牆 iptables

不淨之心發表於2013-03-27
參考:[url]http://czpae86.iteye.com/blog/1634564[/url]來設定,並沒有成功,因為我是把-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT放在commit的前面,不知到什麼原因,一直沒有成功,
後來我把它放在22埠後面,然後就可以了,是啥子原因呢?
[color=red][b]CentOS 6.4[/b][/color]
# cd /etc/sysconfig
# vi iptables

一定要在:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
的後面增加:
[color=blue]-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT[/color]
然後儲存,就可以了
[b][color=red]注意:要是在commit前面增加,貌似也不可以,難道INPUT一定要在一起?[/color][/b]

#[color=red][b]service iptables restart[/b][/color]
iptables:清除防火牆規則: [確定]
iptables:將鏈設定為政策 ACCEPT:filter [確定]
iptables:正在解除安裝模組: [確定]
iptables:應用防火牆規則: [確定]
[color=red]上面操作可能引起其他問題
正確操作如下:[/color]
/sbin/iptables -I INPUT -p tcp --dport 9080 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status



[color=red][b]Fedora17 [/b][/color]
重啟就好


[size=large][color=red][b]Centos 6.5快捷設定埠[/b][/color][/size]
開啟埠:
CentOS 6 iptables 開放埠80 3306 22等

#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
然後儲存:
#/etc/init.d/iptables save
檢視開啟的埠:
# /etc/init.d/iptables status

極端情況

​#重啟防火牆
service iptables restart

相關文章