platinum 请进,关于你写一段iptables代码的问题[2]

[入库:2005年9月19日] [更新:2007年3月24日]

本文简介:

Example iptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT --to-source 194.236.50.155-194.236.50.160:1024-32000 
这个例子中没有写内网的IP地址段,SNAT是默认找到内网IP地址段,然后在转换源地址,不需要自己在命令中手动添加-s 192.168.0.0/24吗? 
[/quote:cdd629466b]
这样的话,任何一个机器都可以用你的机器来做网关进行转发,那岂不是很危险?

[quote:cdd629466b]
如你所说,iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT 
是允许服务器响应外网访问的WEB服务,但是如果WLAN-IP访问结束关掉 
IE,然后又打开IE访问WEB,那你说怎么和这个WEB建立连接呢?
[/quote:cdd629466b]
我先纠正一下,我上面的脚本有个小问题
iptables -A FORWARD -p tcp -d 内网WEB1 --dport 80 -j ACCEPT 
iptables -A FORWARD -p tcp -d 内网WEB2 --dport 80 -j ACCEPT 
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT 
应该是这3行,把“-s”换成“-d”
意思是说
外部的数据包通向内网IP的,ACCEPT
而内部WEB相应外部引起的DNAT的被动连接,去回应外部的数据包(ESTABLISHED状态)的,ACCEPT
RELATED是由一个已授权端口的程序发起的新连接状态,这个是FTP要用到的,写上也没关系

[quote:cdd629466b]
你回复同意“如果已连接的数据已经结束,那么它有产生新数据连接,那就没有办法连接了啊 ”这个说话,那就没有办法访问WEB服务。 
我感觉有点糊涂,你能在说明白点 
[/quote:cdd629466b]
这个怎么解释呢,我不太会用中文翻译过来说,我给你摘抄一段英文原文吧
[quote:cdd629466b]
       --state state
              Where  state  is a comma separated list of the connection states
              to match.  Possible states are INVALID meaning that  the  packet
              could  not  be identified for some reason which includes running
              out of memory and ICMP errors  which  don't  correspond  to  any
              known connection, ESTABLISHED meaning that the packet is associ-
              ated with a connection which has seen  packets  in  both  direc-
              tions, NEW meaning that the packet has started a new connection,
              or otherwise associated with a connection  which  has  not  seen
              packets  in both directions, and RELATED meaning that the packet
              is starting a new connection, but is associated with an existing
              connection, such as an FTP data transfer, or an ICMP error.
[/quote:cdd629466b]
是不是好理解呢?

[quote:cdd629466b]
谢谢了
[/quote:cdd629466b]
不客气 :mrgreen:

 zifengling 回复于:2005-03-03 15:23:58 platinum兄,您真是太伟大了!看了您给我发的回复以及这篇讨论理解的更透了!

您真有耐心,佩服什么时候到苏州我请您喝酒!!!

 platinum 回复于:2005-03-03 15:53:02 不客气
苏州是个好地方,有机会一定去玩玩! :mrgreen:

 海之蓝 回复于:2005-03-03 16:33:41 呵呵,platinum  你是我见到最有耐心的斑斑了,真的是很感动。

你说这样理解是不是可以的啊?
先端口映射建立ESTABLISH连接,然后端口映射没有转发功能,
所以加FORWARD来进行转发,
linux是一次选择,然后后面的数据直接转发吗?

“引用: 

我对这个例子理解不清楚 
Example iptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT --to-source 194.236.50.155-194.236.50.160:1024-32000 
这个例子中没有写内网的IP地址段,SNAT是默认找到内网IP地址段,然后在转换源地址,不需要自己在命令中手动添加-s 192.168.0.0/24吗? 
 

这样的话,任何一个机器都可以用你的机器来做网关进行转发,那岂不是很危险? ”

我的想法就是想让内部网的IP全都上上网,如果加这个网段应该不算危险把,你觉得呢?

我也在苏州呀,zifengling 你在苏州哪里啊?

 platinum 回复于:2005-03-03 16:47:18 [quote:0927eaf25c]
你说这样理解是不是可以的啊? 

本文关键:platinum 请进,关于你写一段iptables代码的问题
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top