本文档介绍使用NAT多实例的典型案例。

本文档不严格与具体软、硬件版本对应,如果使用过程中与产品实际情况有差异,请参考相关产品手册,或以设备实际情况为准。

本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。

本文档假设您已了解NAT多实例的特性。

3  配置举例

3.1  组网需求

如图1所示,两台CE配置相同的地址连接到PE上,CE 1属于PE的VPN实例1,CE 2属于PE的VPN实例2,两CE分别连接单个的内部局域网,现要求:在PE上配置NAT多实例,使能CE 1和CE 2通过PE的同一公网接口访问Web服务器。

图1 MSR路由器NAT多实例访问公网组网图


为了使CE能够访问Web服务器,需要在PE的NAT多实例的访问控制列表中,配置相应的VPN实例来匹配不同CE的私网数据报文到目的地址。

3.3  使用版本

本举例是在Release 2311版本上进行配置和验证的。

# 进入系统视图
 system-view
# 进入接口视图,配置IP地址。
[CE1] interface ethernet 0/1
[CE1-Ethernet0/1] ip address 202.115.1.2 255.255.255.0
[CE1-Ethernet0/1] quit
# 配置指向PE设备的缺省路由。
[CE1] ip route-static 0.0.0.0 0.0.0.0 202.115.1.1
3.4.2  CE 2的配置
#进入系统视图。
 system-view
# 进入接口视图,配置IP地址。
[CE2] interface ethernet 0/2
[CE2-Ethernet0/2] port link-mode route
[CE2-Ethernet0/2] ip address 202.115.1.2 255.255.255.0
[CE2-Ethernet0/2] quit
# 配置指向PE设备的缺省路由。
[CE2] ip route-static 0.0.0.0 0.0.0.0 202.115.1.1
# 进入系统视图。
 system-view
# 创建访问控制列表。
[PE]acl number 3000
[PE-acl-adv-3000] rule 1 permit ip vpn-instance 1 destination 168.32.15.0 0.0.0.255
[PE-acl-adv-3000] rule 2 permit ip vpn-instance 2 destination 168.32.15.0 0.0.0.255
[PE-acl-adv-3000] quit
# 创建VPN实例1,并配置RD和VPN Target属性。
[PE] ip vpn-instance 1
[PE-vpn-instance-1] route-distinguisher 1:1
[PE-vpn-instance-1] vpn-target 1:1
[PE-vpn-instance-1] quit
# 创建VPN实例2,并配置RD和VPN Target属性。
[PE] ip vpn-instance 2
[PE-vpn-instance-2] route-distinguisher 2:2
[PE-vpn-instance-2] vpn-target 2:2
[PE-vpn-instance-2] quit
# 配置连接CE 1的接口地址并绑定到VPN实例1。
[PE] interface ethernet 0/1
[PE-Ethernet0/1] ip binding vpn-instance 1
[PE-Ethernet0/1] ip address 202.115.1.1 255.255.255.0
[PE-Ethernet0/1] quit
# 配置连接CE 2的接口地址并绑定到VPN实例2。
[PE] interface ethernet 0/2
[PE-Ethernet0/2] ip binding vpn-instance 2
[PE-Ethernet0/2] ip address 202.115.1.1 255.255.255.0
[PE-Ethernet0/2] quit
# 在PE接口上应用ACL 3000并配置接口地址。
[PE] interface ethernet 0/0
[PE-Ethernet0/0] nat outbound 3000
[PE-Ethernet0/0] ip address 168.32.15.5 255.255.255.0
[PE-Ethernet0/0] quit
# 配置VPN实例1和VPN实例2到Web server的缺省路由。
[PE] ip route-static vpn-instance 1 0.0.0.0 0.0.0.0 168.32.15.6 public
[PE] ip route-static vpn-instance 2 0.0.0.0 0.0.0.0 168.32.15.6 public
# 配置到CE 1和CE 2所接局域网的VPN实例静态路由。
[PE] ip route-static vpn-instance 1 192.168.1.0 255.255.255.0 202.115.1.2
[PE] ip route-static vpn-instance 2 192.168.1.0 255.255.255.0 202.115.1.2
3.5  验证配置
# 在CE 1上ping Web服务器的地址,查看能否ping通。
 ping 168.32.15.6
PING 168.32.15.6: 56  data bytes, press CTRL_C to break
Reply from 168.32.15.6: bytes=56 Sequence=0 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=1 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=2 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=3 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=4 ttl=254 time=1 ms
--- 168.32.15.6 ping statistics ---
5 packet(s)
transmitted
5 packet(s)
received
0.00% packet loss
round-trip min/avg/max = 1/1/1 ms
# 在CE 2上ping Web服务器的地址,查看能否ping通。
 ping 168.32.15.6
PING 168.32.15.6: 56  data bytes, press CTRL_C to break
Reply from 168.32.15.6: bytes=56 Sequence=0 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=1 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=2 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=3 ttl=254 time=1 ms
Reply from 168.32.15.6: bytes=56 Sequence=4 ttl=254 time=1 ms
--- 168.32.15.6 ping statistics ---
5 packet(s)
transmitted
5 packet(s)
received
0.00% packet loss
round-trip min/avg/max = 1/1/1 ms
# 在PE上察看VPN实例1和VPN实例2的地址转换表项。
 display nat session
Pro    GlobalAddr:Port        LocalAddr:Port         DestAddr:Port
ICMP   168.32.15.5:1033       202.115.1.2:16         168.32.15.6:16
GlobalVPN:
---         LocalVPN: 1
status: ---            TTL:
---               Left: 00:00:08
Pro    GlobalAddr:Port        LocalAddr:Port         DestAddr:Port
ICMP   168.32.15.5:1032       202.115.1.2:71         168.32.15.6:71
GlobalVPN: ---         LocalVPN: 2
status: ---            TTL:
---               Left: 00:00:00
# 通过指定不同的VPN实例名称,精确查询该VPN实例的地址转换表项。
 display nat session vpn-instance 1
Pro    GlobalAddr:Port        LocalAddr:Port         DestAddr:Port
ICMP   168.32.15.5:1032       202.115.1.2:71         168.32.15.6:71
GlobalVPN: ---         LocalVPN: 1
status: ---            TTL:
---               Left: 00:00:00
 display nat session vpn-instance 2
Pro    GlobalAddr:Port        LocalAddr:Port         DestAddr:Port
ICMP   168.32.15.5:1033       202.115.1.2:16         168.32.15.6:16
GlobalVPN: ---         LocalVPN: 2
status: ---            TTL:
---               Left: 00:00:27
·     CE 1:
#
sysname CE1
#
interface Ethernet0/1
port link-mode route
ip address 202.115.1.2 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 202.115.1.1
#
·     CE 2:
#
sysname CE2
#
interface Ethernet0/2
port link-mode route
ip address 202.115.1.2 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 202.115.1.1
#
·     PE:
#
sysname PE
#
ip vpn-instance 1
route-distinguisher 1:1
vpn-target 1:1 export-extcommunity
vpn-target 1:1 import-extcommunity
#
ip vpn-instance 2
route-distinguisher 2:2
vpn-target 2:2 export-extcommunity
vpn-target 2:2 import-extcommunity
#
acl number 3000
rule 1 permit ip vpn-instance 1 destination 172.32.0.0 0.0.255.255
rule 2 permit ip vpn-instance 2 destination 172.32.0.0 0.0.255.255
#
interface Ethernet0/0
port link-mode route
nat outbound 3000
ip address 168.32.15.5 255.255.0.0
#
interface Ethernet0/1
port link-mode route
ip binding vpn-instance 1
ip address 202.115.1.1 255.255.255.0
#
interface Ethernet0/2
port link-mode route
ip binding vpn-instance 2
ip address 202.115.1.1 255.255.255.0
#
ip route-static vpn-instance 1 0.0.0.0 0.0.0.0 168.32.15.6 public
ip route-static vpn-instance 1 192.168.1.0 255.255.255.0 202.115.1.2
ip route-static vpn-instance 2 0.0.0.0 0.0.0.0 168.32.15.6 public
ip route-static vpn-instance 2 192.168.1.0 255.255.255.0 202.115.1.2
#
4  相关资料
·     H3C MSR 系列路由器 命令参考(V5)-R2311
·     H3C MSR 系列路由器 配置指导(V5)-R2311