目录
一、实验拓扑
二、实验需求
三、实验思路
1、配置公网ip地址如图所示。
2、R2/3/4配置ospf。配置MPLS。
3、配置MPLS VPN,在R2/3/4间配置。在R2上创建名为a的vrf空间和b的vrf空间,在R4上创建名为a1的vrf空间和b1的vrf空间。
4、PE与PE间建立MP-BPG邻居关系。
5、R1和R5端编写静态路由,R6和R7编写动态路由。CE端与PE端交互路由,之后使用双向重发布,实现路由共享。配置缺省实现R7访问公网环回。
四、实验步骤
1、配置公网ip地址
2、配置公网ospf,配置MPLS。
查看ospf邻居关系
配置MPLS
[r2]mpls lsr-id 2.2.2.2 必须先定义mpls的router-id,要为本地设备的真实ip地址,且邻居可达,因为该地址将用于建立TCP会话,建议使用环回地址
[r2]mpls 再开启mpls协议
[r2-mpls]mpls ldp 再激活LDP协议
[r2-mpls-ldp]q 之后需要在所有标签经过的接口上开启协议
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]mpls 先开启MPLS
[r2-GigabitEthernet0/0/0]mpls ldp 再激活LDP协议
R3、4同理
查看tcp会话建立
3、配置MPLS VPN,在R2/3/4间配置。
[r2]ip vpn-instance a 创建名为a的vrf空间
[r2-vpn-instance-a]ipv4-family 进入IPV4的配置模式下
[r2-vpn-instance-a-af-ipv4]route-distinguisher 1:1 RD值
[r2-vpn-instance-a-af-ipv4]vpn-target 1:1 RT值 必须对端的PE端一致
[r2]interface GigabitEthernet 0/0/1 进入链接CE端的接口
[r2-GigabitEthernet0/0/1]ip binding vpn-instance a 关联到vrf空间
[r2-GigabitEthernet0/0/1]ip address 192.168.2.2 24 配置私有ip地址
[r2]ip vpn-instance b 创建名为a的vrf空间
[r2-vpn-instance-a]ipv4-family 进入IPV4的配置模式下
[r2-vpn-instance-a-af-ipv4]route-distinguisher 2:2 RD值
[r2-vpn-instance-a-af-ipv4]vpn-target 2:2 RT值 必须对端的PE端一致
[r2]interface GigabitEthernet 0/0/2 进入链接CE端的接口
[r2-GigabitEthernet0/0/2]ip binding vpn-instance a 关联到vrf空间
[r2-GigabitEthernet0/0/2]ip address 192.168.2.2 24 配置私有ip地址
R4同理
4、R2和R4间建立MP-BPG邻居关系。
[r2]bgp 1
[r2-bgp]router-id 2.2.2.2
先和对端建立正常BGP邻居关系,可用于传递正常的公网路由
[r2-bgp]pe 4.4.4.4 as-number 1
[r2-bgp]pe 4.4.4.4 connect-interface LoopBack 0
[r2-bgp]pe 4.4.4.4 next-hop-local
同时还需要再在IPV4的家族模式中,与对端建立一个VPNV4的关系,用于传递VPNV4路由
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable
[r4]bgp 1
[r4-bgp]router-id 4.4.4.4
先和对端建立正常BGP邻居关系,可用于传递正常的公网路由
[r4-bgp]pe 2.2.2.2 as-number 1
[r4-bgp]pe 2.2.2.2 connect-interface LoopBack 0
[r4-bgp]pe 2.2.2.2 next-hop-local
同时还需要再在IPV4的家族模式中,与对端建立一个VPNV4的关系,用于传递VPNV4路由
[r4-bgp]ipv4-family vpnv4
[r4-bgp-af-vpnv4]peer 2.2.2.2 enable
5、R1和R5端编写静态路由,R6和R7编写动态路由。CE端与PE端交互路由,之后使用双向重发布,实现路由共享。
配置IP地址
R1和R5端编写静态路由,R6和R7编写动态路由。 CE端与PE端交互路由,之后使用双向重发布,实现路由共享。
[R1]ip route-static 192.168.3.0 255.255.255.0 192.168.2.2
[R1]ip route-static 192.168.4.0 255.255.255.0 192.168.2.2
[r2]bgp 1
[r2-bgp]ipv4 vpn-instance a
[r2-bgp-a]import-route direct
[r2-bgp-a]import-route static
[R5]ip route-static 192.168.1.0 255.255.255.0 192.168.3.1
[R5]ip route-static 192.168.2.0 255.255.255.0 192.168.3.1
[r4]bgp 2
[r4-bgp]ipv4 vpn-instance a1
[r4-bgp-a1]import-route direct
[r4-bgp-a1]import-route static
[R6]rip
[R6-rip-1] version 2
[R6-rip-1] network 192.168.2.0
[R6-rip-1] network 192.168.1.0
[R2]rip 1 vpn-instance b
[R2-rip-1]version 2
[R2-rip-1] network 192.168.2.0
[R2-rip-1] import-route bgp
[r2]bgp 2
[r2-bgp]ipv4-family vpn-instance a
[r2-bgp-a]import-route rip 1
[R4]ospf 1
[R4-ospf-1]network 47.1.1.1 0.0.0.0
[r4]ospf 2 vpn-instance b1
[r4-ospf-2]area 0
[r4-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[r4]bgp 2
[r4-bgp]ipv4-family vpn-instance b1
[r4-bgp-a]import-route ospf 2
[r4]ospf 2 vpn-instance b1
[R4-ospf-2]network 192.168.3.1 0.0.0.0
[r4-ospf-2]import-route bgp
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1] area 0.0.0.0
[R7-ospf-1] network 192.168.3.2 0.0.0.0
[R7-ospf-1] network 192.168.4.2 0.0.0.0
[R7]ip route-static 0.0.0.0 0.0.0.0 47.1.1.1
五、测试
R1可以访问R5但是不能访问R7
R6可以访问R7但是不能访问R5
R7可以访问公网环回