实验拓扑:
需求:
HA 内部地址访问 Yinlian 的外部地址时,源地址做如下转换:
序号 | HA 真实源地址 | 目的地址 | 源转换后地址 |
---|---|---|---|
1 |
10.3.0.42/32 |
31.0.0.18/32 | 10.11.15.252 |
31.0.0.50/32 | |||
41.0.1.0/24 | |||
10.23.1.184 | |||
2 |
10.16.0.68/32 |
31.0.0.18/32 | 10.255.15.10 |
31.0.0.50/32 | |||
41.0.1.0/24 |
acl name YinLian2 3998
rule 5 permit ip source 10.3.0.42 0 destination 31.0.0.18 0
rule 10 permit ip source 10.3.0.42 0 destination 31.0.0.50 0
rule 15 permit ip source 10.3.0.42 0 destination 41.0.1.0 0.0.0.255
rule 20 permit ip source 10.3.0.42 0 destination 10.23.1.184 0
acl name YinLian 3999
rule 5 permit ip source 10.16.0.68 0 destination 31.0.0.18 0
rule 10 permit ip source 10.16.0.68 0 destination 31.0.0.50 0
rule 15 permit ip source 10.16.0.68 0 destination 41.0.1.0 0.0.0.255
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
nat static global 10.11.15.252 inside 10.3.0.42 netmask 255.255.255.255 acl 3998
nat static global 10.255.15.10 inside 10.16.0.68 netmask 255.255.255.255 acl 3999
ip route-static 10.23.1.184 255.255.255.255 12.1.1.1 description YL_shengchan
ip route-static 31.0.0.18 255.255.255.255 12.1.1.1 description YL_shengchan
ip route-static 31.0.0.50 255.255.255.255 12.1.1.1 description YL_shengchan
ip route-static 41.0.1.0 255.255.255.0 12.1.1.1 description YL_ceshi
ip ip-prefix YL_shengchan_CUC index 5 permit 31.0.0.18 32
ip ip-prefix YL_shengchan_CUC index 10 permit 31.0.0.50 32
ip ip-prefix YL_shengchan_CUC index 15 permit 41.0.1.0 24
ip ip-prefix YL_shengchan_CUC index 20 permit 10.23.1.184 32
route-policy S2O permit node 30
description YL_shengchan_CUC
if-match ip-prefix YL_shengchan_CUC
apply cost 150
ospf 80
import-route static route-policy S2O
area 0.0.0.0
network 23.1.1.0 0.0.0.255
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
interface LoopBack1
ip address 31.0.0.18 255.255.255.255
#
interface LoopBack2
ip address 31.0.0.50 255.255.255.255
#
interface LoopBack3
ip address 41.0.1.1 255.255.255.255
#
interface LoopBack4
ip address 10.23.1.184 255.255.255.255
ip route-static 10.11.15.252 255.255.255.255 12.1.1.2
ip route-static 10.255.15.10 255.255.255.255 12.1.1.2
interface GigabitEthernet0/0/0
ip address 23.1.1.3 255.255.255.0
interface LoopBack1
ip address 10.3.0.42 255.255.255.255
#
interface LoopBack2
ip address 10.16.0.68 255.255.255.255
#
interface LoopBack10
ip address 1.1.1.1 255.255.255.255
#
ospf 80
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 10.3.0.42 0.0.0.0
network 10.16.0.68 0.0.0.0
network 23.1.1.0 0.0.0.255
测试:
- 在 HA 上带 10.3.0.42 的源地址 ping 31.0.0.18
[HA]ping -a 10.3.0.42 31.0.0.18
PING 31.0.0.18: 56 data bytes, press CTRL_C to break
Reply from 31.0.0.18: bytes=56 Sequence=1 ttl=254 time=177 ms
Reply from 31.0.0.18: bytes=56 Sequence=2 ttl=254 time=742 ms
Reply from 31.0.0.18: bytes=56 Sequence=3 ttl=254 time=1 ms
Reply from 31.0.0.18: bytes=56 Sequence=4 ttl=254 time=7 ms
Reply from 31.0.0.18: bytes=56 Sequence=5 ttl=254 time=128 ms
--- 31.0.0.18 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/211/742 ms
PE 路由器上查看 NAT Session,符合要求:
[PE]display nat session all NAT Session Table Information:Total : 0
[PE]display nat session all
NAT Session Table Information:
Protocol : ICMP(1)
SrcAddr Vpn : 10.3.0.42
DestAddr Vpn : 31.0.0.18
Type Code IcmpId : 8 0 60843
NAT-Info
New SrcAddr : 10.11.15.252
New DestAddr : ----
New IcmpId : ----
Total : 1
- 在 HA 上带 10.16.0.68 的源地址 ping 31.0.0.18
--- 31.0.0.18 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 2/4/8 ms
PE 路由器上查看 NAT Session,符合要求:
[PE]display nat session all NAT Session Table Information: Protocol : ICMP(1) SrcAddr Vpn : 10.16.0.68 DestAddr Vpn : 31.0.0.18 Type Code IcmpId : 8 0 61099 NAT-Info New SrcAddr : 10.255.15.10 New DestAddr : ---- New IcmpId : ----Total : 1
- 在 HA 上带 1.1.1.1 的源地址 ping 31.0.0.18
--- 31.0.0.18 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PE 路由器上查看 NAT Session,由于没有匹配上 ACL,所以没有进行 NAT 转换:
[PE]display nat session all NAT Session Table Information:Total : 0
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于