Advertisement

H3C VRF实验

阅读量:

不同VPN之间的路由隔离一般通过VPN实例(VPN-instance) 实现,VPN实例又称为VRF(Virtual Routing and Forwarding,虚拟路由和转发) 实例。设备上每个VPN实例都有相对独立的路由表和FIB(Forwarding Information Base,转发信息库) ,确保VPN数据的独立性和安全性。

实验拓扑图:

实验要求:

RT1-RT2分别对应2个内网网关,用户流量在POP设备上通过VRF进行隔离,同时需要经过GW设备访问SR服务器

配置步骤

首先配置各接口的IP地址和掩码

配置VRF

配置静态路由联通网络

RT1

sys

[H3C]sysname RT1

[RT1]int g0/0

[RT1-GigabitEthernet0/0]ip add 100.1.1.1 24

[RT1-GigabitEthernet0/0]quit

[RT1]ip route-static 0.0.0.0 0 100.1.1.3

[RT1]quit

RT2

sys

[H3C]sysname RT2

[RT2]int g0/0

[RT2-GigabitEthernet0/0]ip add 100.2.2.2 24

[RT2-GigabitEthernet0/0]quit

[RT2]ip route-static 0.0.0.0 0 100.2.2.3

POP

sys

[H3C]sysname POP

[POP]ip vpn-instance RT1 #配置vpn实例-RT1

[POP-vpn-instance-RT1]route-distinguisher 11:11 # VPN实例-RT1的路由区分器值11:11 。11(自治系统号)和11(自定义数)组成

[POP-vpn-instance-RT1]vpn-target 11:11 import-extcommunity #为VPN实例IPv4地址族配置VPN-target扩展团体属性,定义可以接收带有指定扩展团体属性值的路由信息

[POP-vpn-instance-RT1]vpn-target 11:11 export-extcommunity#指定vpn-target添加到VPN实例地址族的出方向VPN-Target扩展团体属性列表中

[POP]quit

[POP]ip vpn-instance RT2#配置vpn实例-RT2

[POP-vpn-instance-RT2]route-distinguisher 22:22 #设置vpn实例区分值22:22

[POP-vpn-instance-RT2]vpn-target 22:22 import-extcommunity#为VPN实例IPv4地址族配置VPN-target扩展团体属性,定义可以接收带有指定扩展团体属性值的路由信息

[POP-vpn-instance-RT2]vpn-target 22:22 export-extcommunity#指定vpn-target添加到VPN实例地址族的出方向VPN-Target扩展团体属性列表中

[POP-vpn-instance-RT2]quit

[POP]ip vpn-instance POP

[POP-vpn-instance-POP]route-distinguisher 33:33

[POP-vpn-instance-POP]vpn-target 33:33 import-extcommunity

[POP-vpn-instance-POP]vpn-target 33:33 export-extcommunity

[POP-vpn-instance-POP]quit

[POP]int g0/0

[POP-GigabitEthernet0/0]ip binding vpn-instance RT1

Some configurations on the interface are removed.

[POP-GigabitEthernet0/0]int g0/1

[POP-GigabitEthernet0/1]ip binding vpn-instance RT2

Some configurations on the interface are removed.

[POP-GigabitEthernet0/1]int g0/2

[POP-GigabitEthernet0/2]ip binding vpn-instance POP

Some configurations on the interface are removed.

[POP-GigabitEthernet0/2]quit

[POP]int g0/0

[POP-GigabitEthernet0/0]ip add 100.1.1.3 24

[POP-GigabitEthernet0/0]quit

[POP]int g0/1

[POP-GigabitEthernet0/1]

[POP-GigabitEthernet0/1]ip add 100.2.2.3 24

[POP-GigabitEthernet0/1]quit

[POP]int g0/2

[POP-GigabitEthernet0/2]ip add 100.3.3.3 24

[POP-GigabitEthernet0/2]quit

GW

sys

[H3C]sysname GW

[GW-GigabitEthernet0/0]int g0/1

[GW-GigabitEthernet0/1]ip add 100.4.4.4 24

[GW-GigabitEthernet0/1]nat outbound

[GW-GigabitEthernet0/1]int g0/0

[GW-GigabitEthernet0/0]ip add 100.3.3.4 24

[GW-GigabitEthernet0/0]quit

[GW]ip route-static 100.1.1.0 24 10.3.3.3

[GW]ip route-static 100.2.2.0 24 10.3.3.3

SR

sys

[H3C]sysname SR

[SR]int g0/0

[SR-GigabitEthernet0/0]ip add 100.4.4.5 24

[SR-GigabitEthernet0/0]

此时我们查看设备接口都是正常的,但是查看路由表项却一条都没有了。

如果我们从POP上请求SR,将是不通的,因为上行口GE0/2绑定了VPN实例,所以要把路由添加到VPN实例POP中。

[POP]ip route-static vpn-instance POP 0.0.0.0 0 100.3.3.4

查看路由表和执行ping命令时都要带VPN实例,如下所示。

这里我们为什么要配置一个nat,是因为这里没有回程路由,所以需要配置一个nat。

配置路由泄露,其实就是在一个VPN示例中添加另一个VPN实例的下一跳,比如在VPN实例RT1中添加去往SR的默认路由。

[POP]ip route-static vpn-instance RT1 0.0.0.0 0 vpn-instance POP 100.3.3.4

对应的,也要在VPN实例POP中添加回程路由。

[POP]ip route-static vpn-instance POP 100.1.1.0 24 vpn-instance RT1 100.1.1.1

查看vpn-instance RT1路由表和vpn-instance POP路由表

同理,再增加VPN实例RT2和POP之间的互访路由。

路由已经建立,现在,从RT1上就能正常访问SR了。

同理,再增加VPN实例RT2和POP之间的互访路由。

[POP]ip route-static vpn-instance RT2 0.0.0.0 0 vpn-instance POP 100.3.3.4

[POP]ip route-static vpn-instance POP 100.2.2.0 24 vpn-instance RT2 100.2.2.2

但是也有了一个新的问题,那就是RT1、RT2也能互访了,这让VPN实例变得没有意义了。

tracert查看一下转发路径。

我们发现RT2和RT1之间的互访是由GW实现的,那我们在GW设备的接口GE0/0上加一个包过滤行不行呢?

[GW]acl advanced 3000

[GW-acl-ipv4-adv-3000]rule 0 deny ip source 100.1.1.0 0.0.0.255 destination 100.

2.2.0 0.0.0.255

[GW-acl-ipv4-adv-3000]rule 5 deny ip source 100.2.2.0 0.0.0.255 destination 100.

1.1.0 0.0.0.255

[GW-acl-ipv4-adv-3000]quit

[GW]int g0/0

[GW-GigabitEthernet0/0]packet-filter ?

INTEGER<2000-2999> Basic ACL number

INTEGER<3000-3999> Advanced ACL number

INTEGER<4000-4999> Layer 2 ACL number

default Default action

ipv6 Specify an IPv6 ACL

mac Specify a Layer 2 ACL

name Specify an ACL by its name

[GW-GigabitEthernet0/0]packet-filter 3000 inbound#数据包过滤匹配acl 3000的流量拒绝通过

再次测试

[RT1]ping 100.2.2.2
Ping 100.2.2.2 (100.2.2.2): 56 data bytes, press CTRL+C to break
Request time out
Request time out
Request time out
Request time out
Request time out

--- Ping statistics for 100.2.2.2 ---
5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss
[RT1]%Apr 16 21:57:56:919 2024 RT1 PING/6/PING_STATISTICS: Ping statistics for 100.2.2.2: 5 packet(s) transmitted, 0 packet(s) received, 100.0% packet loss.
[RT1]tracert 100.2.2.2
traceroute to 100.2.2.2 (100.2.2.2), 30 hops at most, 40 bytes each packet, press CTRL+C to break
1 100.1.1.3 (100.1.1.3) 0.547 ms 0.609 ms 0.461 ms
2 100.3.3.4 (100.3.3.4) 1.315 ms !X 0.704 ms !X 1.226 ms !X

[RT1]ping 100.4.4.5

Ping 100.4.4.5 (100.4.4.5): 56 data bytes, press CTRL+C to break

56 bytes from 100.4.4.5: icmp_seq=0 ttl=253 time=1.359 ms

56 bytes from 100.4.4.5: icmp_seq=1 ttl=253 time=3.191 ms

56 bytes from 100.4.4.5: icmp_seq=2 ttl=253 time=3.275 ms

56 bytes from 100.4.4.5: icmp_seq=3 ttl=253 time=3.395 ms

56 bytes from 100.4.4.5: icmp_seq=4 ttl=253 time=2.038 ms

全部评论 (0)

还没有任何评论哟~