路由策略专题(七)之屠龙宝刀Route

  |   0浏览

NAT是网络中的常用场景,我们就来看一下Route-map在NAT中的使用场景吧。

关于NAT的基本知识过于基础这里就不在赘述了。我们就来简单的看一下route-map的典型应用情景。

首先我们来看一下基本的写法。做NAT时我们只能使用ACL进行抓取,因为实际上是对数据的操作。

#抓取感兴趣流

access-list 1 permit x.x.x.x y.y.y.y 

#写route-map

route-map NAT permit 10

match ip add 1

#希望与那个出接口匹配

match interface e0/1

#调用Route-map

ip nat inside source route-map NAT interface e0/1 overload

我们先来看一下使用route-map与传统nat方法的好处:

针对一组感兴趣流,可以采用多组nat(可以支持线路热备)

可以实现针对不同策略在实现不同的Route-map的可能性

情景,单出口双上行。

spacer.gif图片.png

实验拓扑:

R1是公司内部出口,有两条上行线路,分别有两条静态路由指向不同的路由器。

R2是ISP1的路由器,lo0:8.8.8.8

R3是ISP2的路由器,lo0:8.8.8.8

内部网络由R4模拟,lo1接口:10.0.100.1/24;lo2接口:10.0.200.1/24

互联网用8.8.8.8模拟

要求:

实现按颜色分流

当某条链路中断时,要求路由表中相关的静态路由不再加表。

并且可以实现线路的自动热备转换。

实验配置:

-----------------------路由检测-----------------------------

!

ip sla 1

icmp-echo 12.1.1.2 source-interface Ethernet0/1

threshold 1000

timeout 1000

frequency 1

!

ip sla 2

icmp-echo 13.1.1.3 source-interface Ethernet0/2

threshold 1000

timeout 1000

frequency 1

!

ip sla schedule 1 life forever start-time now

ip sla schedule 2 life forever start-time now

!

track 1 ip sla 1 reachability

track 2 ip sla 2 reachability

!

ip route 0.0.0.0 0.0.0.0 Ethernet0/1 12.1.1.2 track 1

ip route 0.0.0.0 0.0.0.0 Ethernet0/2 13.1.1.3 track 2

!

-----------------------------分流----------------------------------

!

route-map PBR permit 10

match ip address 1

set ip next-hop verify-availability 12.1.1.2 1 track 1

set ip next-hop verify-availability 13.1.1.3 2 track 2

set ip next-hop 12.1.1.2 13.1.1.3

route-map PBR permit 20

match ip address 2

set ip next-hop verify-availability 13.1.1.3 1 track 2

set ip next-hop verify-availability 12.1.1.2 2 track 1

set ip next-hop 13.1.1.3 12.1.1.2

!

--------------------------------NAT---------------------------------

!

route-map NAT1 permit 10

match ip address 1 2

match interface Ethernet0/1

!

route-map NAT2 permit 10

match ip address 2 1

match interface Ethernet0/2

!

ip nat inside source route-map NAT1 interface Ethernet0/1 overload

ip nat inside source route-map NAT2 interface Ethernet0/2 overload

!

实验验证:

先来查看一下R1的路由表,可以发现有两条默认路由分别指向两个不通的ISP

spacer.gif图片.png

在正常情况下分别尝试两个网段访问互联网8.8.8.8。通过traceroute和R1上查看NAT转换表可得的确如要求所示。

spacer.gif图片.png

spacer.gif图片.png

假设,R1-R2链路发生故障,shutdown R2的e0/0口模拟。发现两个网段仍均可达,通过查看R1的NAT转换表可得,无论是10.0.100.0网段还是10.0.200.0网段均使用了R1的E0/2口作为出口。由此可得满足需求

图片.pngspacer.gif

图片.png

spacer.gif

原文地址:https://blog.51cto.com/14851874/2507048