免费注册 查看新帖 |

Chinaunix

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

iptables nat设置问题不通 [复制链接]

论坛徽章:
3
2015亚冠之卡尔希纳萨夫
日期:2015-08-04 19:46:43数据库技术版块每日发帖之星
日期:2015-08-07 06:20:00数据库技术版块每日发帖之星
日期:2016-08-15 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-05-12 17:01 |只看该作者 |倒序浏览
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

iptables -A INPUT -p icmp -j ACCEPT
iptables -A OUTPUT -p icmp -j ACCEPT
iptables -A INPUT -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -t udp --dport 53 -j ACCEPT
iptables -A OUTPUT -t udp --dport 53 -j ACCEPT
(设置到这儿,我是可以在linux机器上ping通外部的机器的.如ping 210.22.70.3 ping www.online.sh.cn)

接下来我设置nat
iptables -t nat -F
iptables -t nat -X
iptalbles -t nat -P POSTROUTING ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to-source *.*.*.*
iptables -A FORWARD -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp --dprot 80 -j ACCEPT
iptables -A FORWARD -p icmp -j ACCEPT
(写好这些以后发现问题:192.168.0.0网段的计算机可以ping linux的内网卡192.168.0.1和外网卡*.*.*.*,但是无法ping通外网,linux计算机还是正常的!

请各位大大指点迷津!!!

论坛徽章:
0
2 [报告]
发表于 2005-05-12 17:41 |只看该作者

iptables nat设置问题不通

iptables -A FORWARD -m state --state NEW,ESTABLISHED -j ACCEPT
这个不对吧!

论坛徽章:
0
3 [报告]
发表于 2005-05-12 18:04 |只看该作者

iptables nat设置问题不通

iptables -A INPUT -t udp --dport 53 -j ACCEPT
iptables -A OUTPUT -t udp --dport 53 -j ACCEPT

这两行语法肯定不对,怎么会-t udp?!

你的内网计算机不能ping通外网,上网正常么?

论坛徽章:
0
4 [报告]
发表于 2005-05-12 18:11 |只看该作者

iptables nat设置问题不通

应该是笔误:)

论坛徽章:
3
2015亚冠之卡尔希纳萨夫
日期:2015-08-04 19:46:43数据库技术版块每日发帖之星
日期:2015-08-07 06:20:00数据库技术版块每日发帖之星
日期:2016-08-15 06:20:00
5 [报告]
发表于 2005-05-13 12:13 |只看该作者

iptables nat设置问题不通

谢谢两位大大,这却是是笔误
原来不通是因为我忘记设置:
echo "1" >; /proc/sys/net/ipv4/ip_forward

加了以上这条转发设置后现在网络访问正常了,但是又有问题:
就是192.168内网telnet/ssh/ftp/smtp/pop等都可以使用,但是我想只能使用web服务,因此我在filter表的FORWARD链中也就只开放了53和80,但是不能禁止其他服务的使用!
这难道是因为nat表中的链都是因为默认使用ACCETP的缘故?这个让我比较困惑,因为网上有些例子,都是用filter表的FORWARD链来设置的啊!
各位大大请帮忙解释解释!

论坛徽章:
0
6 [报告]
发表于 2005-05-13 13:28 |只看该作者

iptables nat设置问题不通

iptables -A INPUT -m state --state NEW,ESTABLISHED -j ACCEPT
错在这儿
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP