MPLS基础实验
拓扑图
完成基本ip配置
Core内运行OSPF(进程号100),激活MPLS
PE1配置
router osof 100
router-id 2.2.2.2
network 10.1.23.0 0.0.0.255 area 0
network 2.2.2.2 0.0.0.0 area 0
ip cef //必须开启ip cef
mpls ldp router-id loopback 0 //设置LDP router-id
mpls label range 200 299 //设置标签范围.(为了方便观察实验现象及容易排错)
interface eth0/1
mpls ip //接口下启用mpls
P配置
router ospf 100
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 10.1.23.0 0.0.0.255 area 0
network 10.1.34.0 0.0.0.255 area 0
ip cef
mpls ldp router-id loopback0
mpls label range 300 399
interface eth0/0
mpls ip
interface eth0/1
mpls ip
PE2配置
router ospf 100
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 10.1.34.0 0.0.0.255 area 0
ip cef
mpls ldp router-id loopback0
mpls label range 400 499
interface eth 0/0
mpls ip
在PE上创建VRF,将PE-CE间的接口放入VRF;在PE和CE之间运行IGP协议
PE1配置VRF
ip vrf cisco //创建vrf
rd 234:2 //设置rd值(自定义)
route-target export 234:2 //设置输出rt值(自定义)
route-target import 234:4 //设置输入rt值(自定义)
interface eth0/0
ip vrf forwarding cisco //把物理端口放到名为vrf的cisco里
ip address 10.1.12.2 255.255.255.0
router ospf 1 vrf cisco //进入到cisco宣告路由
network 10.1.12.0 0.0.0.255 area 0
PE2配置VRF
ip vrf cisco
rd 234:4
route-target export 234:4
route-target import 234:2
interface eth0/1
ip vrf forwarding cisco
ip address 10.1.45.4 255.255.255.0
router ospf 1 vrf cisco
network 10.1.45.0 0.0.0.255 area 0
PE配置MP-BGP,建立MP-iBGP邻居关系
PE1配置
router bgp 234
neighbor 4.4.4.4 remote-as 234
neighbor 4.4.4.4 update-source loopback 0
address-family vpnv4 // 开启vpnv4
neighbor 4.4.4.4 activate //激活vpnv4邻居4.4.4.4的连接
PE2配置
router bgp 234
no bgp default ipv4-unicast //关闭维护ipv4bgp的连接
neighbor 2.2.2.2 remote-as 234
neighbor 2.2.2.2 update-source loopback 0
address-family vpnv4
neighbor 2.2.2.2 activate
完成PE-CE之间路由重分布
PE1配置
router bgp 234
address-family ipv4 vrf cisco //进入到名为cisco虚拟路由发布ipv4 ospf路由
redistribute ospf 1 vrf cisco match external 发布ospf路由(math表示内部路由,external表示外部路由)
router ospf 1 vrf cisco
redistribute bgp 234 subnets //ospf发布bgp路由
show ip bgp vpnv4 all //查看vpnv4路由
show ip bgp vpnv4 all labels //查看vpnv4路由标签
PE4配置
router ospf 1 vrf cisco
redistribute bgp 234 subnets //ospf发布bgp路由
router bgp 234 //bgp引入ospf路由,也就是回程路由
address-family ipv4 vrf cisco
redistribute ospf 1 match internal external
测试