一个简单的MPLS ×××实验_休闲
如图, AB 公司与 CD 公司互为竞争对手,且租用同一 ISP 的线路作为分部的互连网络。由于必须确保两公司之间的路由安全性, ISP 采用 MPLS ××× 保障线路可达性及安全性。
其中 AB 公司分公司网关 R1 申请了自治号 1R4 申请自治号 4CD 分公司 R3 申请自治号 3R6 申请自治号 6ISP 自己采用自治号 25 。配置完成后, R1R4 拥有 1.0.0 .0/244.0.0.0/24 的路由; R3R6 拥有 3.0.0.0/246.0.0.0/24 的路由。
R1R3R4R6 配置基本一致。
R1#show run
hostname R1
!
interface Loopback0
 ip address 1.1.1 .1 255.255.255.255
!
interface Loopback1
 description Corp_1
 ip address 1.0.0 .1 255.255.255.0
!
interface Ethernet0/0
 description To R2's E0/0
 ip address 12.0.0 .1 255.255.255.0
!
router bgp 1
 no synchronization
 bgp router-id 1.1.1 .1
 bgp log-neighbor-changes
 network 1.0.0 .0 mask 255.255.255.0
 network 1.1.1 .1 mask 255.255.255.255
 neighbor 12.0.0 .2 remote-as 25
 no auto-summary
!        
end
----------------------------------- 分割线 -----------------------------------
R2R5 配置基本一致
R2#show run
version 12.4
!
hostname R2
!
ip vrf ×××_14
 rd 25:14
 route-target export 25:14
 route-target import 25:14
!
ip vrf ×××_36
 rd 25:36
 route-target export 25:36
 route-target import 25:36
!
ip cef
interface Loopback0
 ip address 2.2.2 .2 255.255.255.255
!
interface Loopback1
 description Insert into ×××_14
 ip address 2.0.0 .2 255.255.255.0
!
interface Ethernet0/0
 description To R1's E0/0
 ip vrf forwarding ×××_14
 ip address 12.0.0 .2 255.255.255.0
!
interface Ethernet0/1
 description To R3's E0/1
 ip vrf forwarding ×××_36
 ip address 23.0.0 .2 255.255.255.0
!
interface Ethernet0/2
 description To R5's E0/2
 ip address 25.0.0.2 255.255.255.0
 mpls ip
!
router eigrp 25
 network 2.2.2 .2 0.0.0.0
 network 12.0.0 .2 0.0.0.0
 network 23.0.0 .2 0.0.0.0
 network 25.0.0.2 0.0.0 .0
 no auto-summary
 eigrp router-id 2.2.2 .2
!
router bgp 25
 no bgp default ipv4-unicast
 bgp log-neighbor-changes
 neighbor 5.5.5 .5 remote-as 25
 neighbor 5.5.5 .5 update-source Loopback0
!
 address-family ipv4
  no synchronization
  no auto-summary
 exit-address-family
 !
 address-family vpnv4
  neighbor 5.5.5 .5 activate
  neighbor 5.5.5 .5 send-community extended
 exit-address-family
 !
 address-family ipv4 vrf ×××_14
  no synchronization
  neighbor 12.0.0 .1 remote-as 1
  neighbor 12.0.0 .1 activate
 exit-address-family
 !
 address-family ipv4 vrf ×××_36
  no synchronization
  neighbor 23.0.0 .3 remote-as 3
  neighbor 23.0.0 .3 activate
 exit-address-family
!
End
R1#show ip route
      1.0.0 .0/8 is variably subnetted, 3 subnets, 2 masks
C        1.0.0 .0/24 is directly connected, Loopback1
C        1.1.1 .1/32 is directly connected, Loopback0
      4.0.0 .0/8 is variably subnetted, 2 subnets, 2 masks
B        4.0.0 .0/24 [20/0] vi a 12.0.0 .2, 00:03:23
B        4.4.4 .4/32 [20/0] vi a 12.0.0 .2, 00:03:23
      12.0.0 .0/8 is variably subnetted, 2 subnets, 2 masks
C        12.0.0 .0/24 is directly connected, Ethernet0/0
R3#show ip route
      3.0.0 .0/8 is variably subnetted, 3 subnets, 2 masks
C        3.0.0 .0/24 is directly connected, Loopback1
C        3.3.3 .3/32 is directly connected, Loopback0
      6.0.0 .0/8 is variably subnetted, 2 subnets, 2 masks
B        6.0.0 .0/24 [20/0] vi a 23.0.0 .2, 00:04:08
B        6.6.6 .6/32 [20/0] vi a 23.0.0 .2, 00:04:08
      23.0.0 .0/8 is variably subnetted, 2 subnets, 2 masks
C        23.0.0 .0/24 is directly connected, Ethernet0/1
----------------------------------- 分割线 -----------------------------------
MPLS ××× 是通过 MPLS 中的标签,对不同 ××× 内的路由进行两次标记,第一次标记在 MPBGP 内,目的是为了区分某条路由在同一 PE ( BGP 进程)上不同的入出口;第二次标记在 MPLS 域内,目的是为了 MPLS 路由器可以传递到 iBGP 对端。由于 MPLS 域内的路由器并不知道 CE 的相关路由,它们只需要根据 PE 所设定的 MPLS 标签进行转发即可,这和 IP over IP 有点类似,也就是通过二次路由减少单次路由时路由表过大所造成的影响。只不过 MPLS 使用标签代替了 IP 头而已。
其中红色字迹表示该部分将对 MPLS 起作用。由于 LDP 需要 IGP 配合才能进行标签分发,因此在 E0/2 启动 MPLS IP ,并启用 EIGRP 作为 IGP 帮助标签分发。
R2#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop   
Label      Label      or Tunnel Id     Switched      interface             
16         Pop Label  5.5.5 .5/32       0             Et0/2      25.0.0.5   
17         No Label   1.0.0 .0/24[V]    0             Et0/0      12.0.0 .1   
18         No Label   1.1.1 .1/32[V]    0             Et0/0      12.0.0 .1   
19         No Label   3.0.0 .0/24[V]    0             Et0/1      23.0.0 .3   
20         No Label   3.3.3 .3/32[V]    0             Et0/1      23.0.0 .3 
可以看到 eigrp 传递的 5.5.5 .5/32 路由已经被 MPLS 贴上标签。
黄、灰底色的内容是不同 MPLS ××× 的相关配置。可以看到,在 CISCO 内部,不同的 MPLS ××× 客户被加入到不同的 VRF 内,并在 BGP 内部调用不同的 IPv4 VRF 地址簇进行标记。而内部 iBGP 则调用 ×××v4 地址簇进行互连。由此, CE 的路由在 IPv4 VRF 内被添加第一个标签 / 去掉第二个标签,并在 ×××v4 内添加第二个标签 / 去掉第一个标签。根据标签, R2R5 进行转发,并在对端完成逆向操作。