某客户从一个ISP_A移到了另一个ISP_B。但是,其WEB服务器由于之前对外公布的是IP地址,且无DNS,因此,要求该服务器搬至ISP_B后,用户依然可以访问原来的IP地址,求方案。

 

假设:ISP_A与ISP_B的两台路由器都可控;原服务器的地址为2.2.2.2/24

原理:在ISP_A(R2)与ISP_B(R1)两台路由器之间做一个GRE的tunnel。当用户访问服务器时,到达ISP_A路由器,在这里,做一条至服务器2.2.2.2的主机路由,指向tunnel的另一端(ISP_B)。数据包通过tunnel到达ISP_B,本机有2.2.2.0段的直连路由,数据包到达2.2.2.2。服务器响应,数据包发送至默认网关ISP_B, 此时数据包就从ISP_B出去了,也就是说数据包来回走的路是不一样的,这样就少了一层GRE封装,理论上讲效率会高。如果想来回都走ISP_A路由,则需要在ISP_B路由器连接服务器的那个端口上启用PBR,将所有源地址是2.2.2.2的包,都指向ISP_A的tunnel上去。

该方案看似复杂,实际实现非常简单,而且是在IP路由层面实现,不挑设备。

实现该功能最简单的办法是NAT就更好了,但目前想不出NAT(在一个端口上实现inside,outside)的实现方法。

 

测试:

      采用dynamips 0.2.8 for linux完成测试(CentOS 6.5, 0.2.8版本总是找libpcap0.9.4库,即使安装上该库). 拓扑图如下。

 

测试用命令:

R9:
dynamips --idle-pc=0x606d0ef0 -P 7200 -p 1:PA-4E unzip-c7200-is-mz.122-37.bin \
-i 9 \
-s 1:1:udp:13321:127.0.0.1:13322 \
-s 1:2:udp:13311:127.0.0.1:13312
#e1/1 to R2 e1/1 #e1/2 to R1 e1/1


R2:
dynamips --idle-pc=0x606d0ef0 -P 7200 -p 1:PA-4E unzip-c7200-is-mz.122-37.bin \
-i 2 \
-s 1:1:udp:13322:127.0.0.1:13321 \
-s 1:2:udp:22221:127.0.0.1:22222
#to R9 #to R22

R22:
dynamips --idle-pc=0x606d0ef0 -P 7200 -p 1:PA-4E unzip-c7200-is-mz.122-37.bin \
-i 22 \
-s 1:1:udp:22222:127.0.0.1:22221


R1:
dynamips --idle-pc=0x606d0ef0 -P 7200 -p 1:PA-4E unzip-c7200-is-mz.122-37.bin \
-i 1 \
-s 1:1:udp:13312:127.0.0.1:13311 \
-s 1:2:udp:12221:127.0.0.1:12222
#to R9 #to R22

R11:
dynamips --idle-pc=0x606d0ef0 -P 7200 -p 1:PA-4E unzip-c7200-is-mz.122-37.bin \
-i 11 \
-s 1:1:udp:12222:127.0.0.1:12221

 

配置:

R9:

interface Loopback0
ip address 9.9.9.9 255.255.255.255
!
interface Ethernet1/1
ip address 3.3.2.1 255.255.255.0
duplex half
!
interface Ethernet1/2
ip address 3.3.1.1 255.255.255.0
duplex half
!
ip route 2.2.2.0 255.255.255.0 3.3.2.2

R1:===========

interface Tunnel0
ip address 192.168.1.1 255.255.255.0
tunnel source 3.3.1.2
tunnel destination 3.3.2.2
!
interface Ethernet1/1
ip address 3.3.1.2 255.255.255.0
duplex half
!
interface Ethernet1/2
ip address 2.2.2.1 255.255.255.0
duplex half
!
ip route 0.0.0.0 0.0.0.0 3.3.1.1

 

R2:===========

interface Tunnel0
ip address 192.168.1.2 255.255.255.0
tunnel source 3.3.2.2
tunnel destination 3.3.1.2
!
interface Ethernet1/1
ip address 3.3.2.2 255.255.255.0
duplex half
!
interface Ethernet1/2
ip address 2.2.2.1 255.255.255.0
duplex half
!
ip route 0.0.0.0 0.0.0.0 3.3.2.1
ip route 2.2.2.2 255.255.255.255 Tunnel0

R11:=============

interface Ethernet1/1
  ip address 2.2.2.2 255.255.255.0

ip route 0.0.0.0 0.0.0.0 2.2.2.1

 

line vty 0 4

password 123

login
!
end

 

R22:=============

interface Ethernet1/1
ip address 2.2.2.3 255.255.255.0
duplex half
!
ip route 0.0.0.0 0.0.0.0 2.2.2.1

posted on 2016-01-21 10:50  胡彼德  阅读(599)  评论(0编辑  收藏  举报