一、搭建实验环境
二、配置
1.ip配置
使用路由协议使运营商设备互通,此处省略
2.mpls域
[r2]mpls lsr-id 2.2.2.2
[r2]mpls
[r2-mpls]lsp-trigger all
[r2-mpls]mpls ldp
[r2]int g0/0/1
[r2-GigabitEthernet0/0/1]mpls
[r2-GigabitEthernet0/0/1]mpls ldp
[r3]mpls lsr-id 3.3.3.3
[r3]mpls
[r3-mpls]lsp-trigger all
[r3-mpls]mpls ldp
[r3-mpls-ldp]int g0/0/0mp
[r3-GigabitEthernet0/0/0]mpls
[r3-GigabitEthernet0/0/0]mpls ldp
[r3]int g0/0/01
[r3-GigabitEthernet0/0/1]mpls
[r3-GigabitEthernet0/0/1]mpls ldp
[r4]mpls lsr-id 4.4.4.4
[r4]mpls
[r4-mpls]lsp-trigger all
[r4-mpls]mpls ldp
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]mpls
[r4-GigabitEthernet0/0/0]mpls ldp
3.配置mpls vpn
r2
[r2]ip vpn-instance ccna //创建名为ccna的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/0 //进入链接CE端的接口
[r2-GigabitEthernet0/0/0]ip binding vpn-instance ccna //关联到vrf空间
[r2-GigabitEthernet0/0/0]ip address 192.168.2.2 24 //配置私有ip地址
[r2]display ip routing-table vpn-instance ccna //查看空间内的私有路由表
[r2]ping -vpn-instance ccna 192.168.2.1 //正常测试将在公有路由表中查询记录
r4
[r4]ip vpn-instance ccnp
[r4-vpn-instance-ccnp]ipv4-family
[r4-vpn-instance-ccnp-af-ipv4]route-distinguisher 1:1
[r4-vpn-instance-ccnp-af-ipv4]vpn-target 1:1 //import-extcommunity export-extcommunity
[r4-vpn-instance-ccnp-af-ipv4]int g0/0/1
[r4-GigabitEthernet0/0/1]ip binding vpn-instance ccnp
[r4-GigabitEthernet0/0/1]ip address 192.168.3.1 24
4.PE与PE间建立MP-BPG邻居关系
[r2]bgp 1
[r2-bgp]router-id 2.2.2.2
[r2-bgp]pe 4.4.4.4 as 1
[r2-bgp]pe 4.4.4.4 con lo0
[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
[r4]bgp 1
[r4-bgp]router-id 4.4.4.4
[r4-bgp]pe 2.2.2.2 as 1
[r4-bgp]pe 2.2.2.2 con lo0
[r4-bgp]pe 2.2.2.2 next-hop-local
[r4-bgp]ipv4-family vpnv4
[r4-bgp-af-vpnv4]pe 2.2.2.2 enable
[r2-bgp]display bgp vpnv4 all peer 查看mp-bgp邻居关系
5.CE端与PE端交互路由
<1>静态路由(r1,r2之间)
CE端
[r1]ip route-static 192.168.3.0 24 192.168.2.2
[r1]ip route-static 192.168.4.0 24 192.168.2.2
PE端
[r2]ip route-static vpn-instance ccna 192.168.1.0 24 192.168.2.1
[r2]bgp 1
[r2-bgp]ipv4-family vpn-instance ccna //将本地vrf空间内的静态和直连路由重发布到BGP协议传递到对端的PE
[r2-bgp-ccna]import-route static
[r2-bgp-ccna]import-route direct
<2>动态路由ospf(r4,r5之间)
CE端
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]a 0
[r5-ospf-1-area-0.0.0.0]network 192.168.4.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 192.168.3.2 0.0.0.0
PE端
[r4]ospf 2 vpn-instance ccnp
[r4-ospf-2]a 0
[r4-ospf-2-area-0.0.0.0]net
[r4-ospf-2-area-0.0.0.0]network 192.168.3.1 0.0.0.0
互相重发布
[r4]bgp 1
[r4-bgp]ipv4-family vpn-instance ccnp
[r4-bgp-ccnp]import-route ospf 2
[r4]ospf 2 vpn-instance ccnp
[r4-ospf-2]import-route bgp
来源:CSDN
作者:吟缺斯汀
链接:https://blog.csdn.net/qq_45491497/article/details/104098774