免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: dbsrv
打印 上一主题 下一主题

[网络管理] 出口有多个IP,能否让每次访问都从不同的IP出去 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2007-05-20 02:54 |只看该作者
原帖由 platinum 于 2007-5-19 15:01 发表于 6楼  
若他们的 IP 是连续的,SNAT 可以实现,否则,就需要修改 SNAT 的源代码来实现离散轮询
另外,若他们使用的不是同网关,那么做 NAT 的时候就不同了,需要设置随机路由 ip route 实现,NAT 的语句也不能再用 SN ...



老大,你能帮忙详细的串讲一下吗?
特别是使用不同网关的细节...
谢谢!期待中...

论坛徽章:
0
12 [报告]
发表于 2007-05-20 06:46 |只看该作者
这个,好像没有什么定式吧,具体问题要具体分析,各种可能性都太多了

论坛徽章:
0
13 [报告]
发表于 2007-05-22 23:39 |只看该作者

回复 #12 platinum 的帖子

to platinum:
iptable里有没有nat address pool的定义?就是定义一个地址池,里面的地址可以是连续的或者是不连续的?
还有,可否像router或switch里可以指定地址池的工作方式,是否rotate等

论坛徽章:
0
14 [报告]
发表于 2007-05-22 23:55 |只看该作者
SNAT 可以实现地址池的功能,但仅限于连续 IP 的状况

  1. iptables -t nat -A POSTROUTING -o ppp0 -j SNAT --to 202.xxx.xxx.1-202.xxx.xxx.31
复制代码

类似这样,在 NAT 出去的时候,源地址是在范围内自动轮询的
若不连续,目前还没有什么好办法,但我想可以通过修改 SNAT 加个离散参数来实现,类似我写的 multiip 模块那样

论坛徽章:
0
15 [报告]
发表于 2007-05-23 10:15 |只看该作者
没有那么复杂,iptables本身就可以实现,不连续的地址可以这样:
iptables -t nat -A POSTROUTING -o ppp0 -j SNAT --to-source 202.xxx.xxx.a --to-source 202.xxx.xxx.b --to-source 202.xxx.xxx.c

man iptables时有这样的解释:
--to-source  ipaddr[-ipaddr][:port-port]

which  can  specify a single new source IP address, an inclusive range of IP addresses, and optionally, a port range (which is only valid if the rule also specifies -p tcp or -p udp).  If  no  port range  is  specified,  then  source  ports below 512 will be mapped to other ports below 512: those between 512 and 1023 inclusive will be mapped to ports below 1024, and other ports will  be  mapped to 1024 or above. Where possible, no port alteration will occur.

You can add several --to-source options.  If you specify more than  one  source  address,  either  via an address range or multiple --to-source options, a simple round-robin (one after another in cycle) takes place between these adresses.

[ 本帖最后由 pangty 于 2007-5-23 10:17 编辑 ]

论坛徽章:
0
16 [报告]
发表于 2007-05-23 10:19 |只看该作者
You can add several --to-source options.  If you specify more than  one  source  address,  either  via an address range or multiple --to-source options, a simple round-robin (one after another in cycle) takes place between these adresses.

原来如此,看资料还是不够仔细,谢谢 pangty 指点
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP