mpls实验-爱代码爱编程
实验拓扑:
实验步骤:
一、配置ip地址,进行OSPF认证
R2:
GigabitEthernet0/0/0 10.1.23.2/24 up up
LoopBack0 2.2.2.2/24 up up(s)
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 10.1.23.2 0.0.0.0
R3:
GigabitEthernet0/0/0 10.1.34.3/24 up up
GigabitEthernet0/0/1 10.1.23.3/24 up up
LoopBack0 3.3.3.3/24 up up(s)
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 10.1.23.3 0.0.0.0
network 10.1.34.3 0.0.0.0
R4:
GigabitEthernet0/0/1 10.1.34.4/24 up up
LoopBack0 4.4.4.4/24 up up(s)
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 10.1.34.4 0.0.0.0
R1:(R5与R1同样配置,目的是通过静态路由配置到达3.0和4.0的网段)
ip route-static 192.168.3.0 255.255.255.0 192.168.2.1
ip route-static 192.168.4.0 255.255.255.0 192.168.2.1
二、进行MPLS认证,解决路由黑洞问题: (R3,R4同R2一样)
[r2]mpls
[r2-mpls]mpls ldp
[r2-mpls-ldp]q
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/1]mpls
[r2-GigabitEthernet0/0/1]mpls ldp
三、MPLS VPN 及BGP配置(R4为同样配置)
配置MPLS VPN
[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/0]ip binding vpn-instance a 关联到vrf空间
[r2-GigabitEthernet0/0/0]ip address 192.168.2.1 24 配置私有ip地址
PE与PE间建立MP-BPG邻居关系
[r2]bgp 1
[r2-bgp]router-id 2.2.2.2
[r2-bgp]pe 4.4.4.4 as-number 2
[r2-bgp]pe 4.4.4.4 connect-interface LoopBack 0
[r2-bgp]pe 4.4.4.4 next-hop-local
[r2-bgp]ipv4-family vpnv4
[r2-bgp-af-vpnv4]peer 4.4.4.4 enable
CE端与PE端交互路由(重发布)
静态:
[r2]ip route-static vpn-instance a 192.168.1.0 24 192.168.2.1
[r2]bgp 1
[r2-bgp]ipv4 vpn-instance a
[r2-bgp-a]import-route direct
[r2-bgp-a]import-route static
动态:
CE端正常启动OSPF或RIP即可(rip和ospf操作过程一样)
PE端,启动VPNV4专用的ospf协议
[r4]ospf 2 vpn-instance b
[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 a
[r4-bgp-a]import-route ospf 2
[r4]ospf 2 vpn-instance b
[r4-ospf-2]import-route bgp
进行验证。
此时,AR7的环回可以ping通AR6的环回。
AR1的环回可以ping通AR5的换回。
(由于实验时马虎,4,7间的线忘配置第二条,7ping3,4,5 的环回明天补齐)