CentOS 6.x & Fedora17 打开8080端口给远程电脑访问:防火墙 iptables

本文详细介绍了如何在CentOS 6.4和6.5中正确配置iptables防火墙以开放特定端口,如80、22、3306和8080等,并提供了具体的步骤和命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考:[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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值