免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4799 | 回复: 10
打印 上一主题 下一主题

[系统安全] 到底是iptables中的那条规则把的80端口封了? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-01-06 11:55 |只看该作者 |倒序浏览
在centos 6.4安装apache后,本机访问正常,其它主机无法访问,使用iptables -F删除所有规则后,其它主机正常访问,
说明iptables中的某条规则限制了。
当前 /etc/sysconfig/iptables文件内容如下:
# 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]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

按我的理解,
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
这三条是没是明显禁止的,都是允许的。但我并没有看到那条规则把80禁止了。

论坛徽章:
2
亥猪
日期:2013-12-24 16:24:04狮子座
日期:2014-01-03 14:56:30
2 [报告]
发表于 2014-01-06 12:24 |只看该作者
iptables -L看看

论坛徽章:
0
3 [报告]
发表于 2014-01-06 12:39 |只看该作者
本帖最后由 pqrs7a 于 2014-01-06 12:41 编辑

[root@syy syy]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

这个就是iptables -L的结果,还是没有看到来,是那条规则把80封了?

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
4 [报告]
发表于 2014-01-06 14:07 |只看该作者
-A INPUT -j REJECT --reject-with icmp-host-prohibited
这句给drop的。
你可以仿造上面那句,添加一条80端口的规则在-A INPUT -j REJECT --reject-with icmp-host-prohibited之前

论坛徽章:
2
亥猪
日期:2013-12-24 16:24:04狮子座
日期:2014-01-03 14:56:30
5 [报告]
发表于 2014-01-06 14:27 |只看该作者
chenyx 发表于 2014-01-06 14:07
-A INPUT -j REJECT --reject-with icmp-host-prohibited
这句给drop的。
你可以仿造上面那句,添加一条8 ...


同意版主的观点。

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
6 [报告]
发表于 2014-01-07 09:21 |只看该作者
试试吧。4楼OK。

论坛徽章:
0
7 [报告]
发表于 2014-01-07 12:57 |只看该作者
-A INPUT -j REJECT --reject-with icmp-host-prohibited

论坛徽章:
0
8 [报告]
发表于 2014-01-07 12:58 |只看该作者
-A INPUT -j REJECT --reject-with icmp-host-prohibited
把这条规则删除就OK了

论坛徽章:
0
9 [报告]
发表于 2014-01-07 17:27 |只看该作者
现在明白了,-A INPUT -j REJECT --reject-with icmp-host-prohibited,在最后,这样规则的作用就是除非前面的规则匹配了,否则都拒绝,并返回 icmp-host-prohibited。
谢谢各位了!

论坛徽章:
0
10 [报告]
发表于 2014-01-07 17:32 |只看该作者
iptables -A INPUT -p tcp --dport 80 -j ACCEPT    打开80端口
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP