MPLS LAB1 - MPLS BGP Interaction

对MPLS的认识都有一段时间了,以前在CCNP的课程里接触过,但没有很仔细地研究。结果不久前的一次面试里面被问到,想了老半天都挤不出几句话来,真是惭愧。所以近来重新把有关的内容翻出来,顺便做做实验巩固一下。
实验是基于Dynamips搭建c3640-js-mz.124-10做的,效果还可以。拓扑如下图:
R4�D�D�D�D�D�D�DR2�D�D�D�D�D�D�DR1�D�D�D�D�D�D�DR3�D�D�D�D�D�D�DR5�D�D�D�D�D�DR6
s0/0         s0/1 s0/0        s0/0 s0/1        s0/0 s0/1      s0/0 s0/1    s0/0
 
先介绍一下MPLS Label在单播IP转发中的分配, Label Allocation in Unicast IP:
  • Labels are assigned to FECs
  • FEC in unicast IP routing is equal to a best prefix found in an IP routing table.
  • This is true only for IGP-derived prefixes
  • BGP-derived prefixes are assigned the label that is used for the BGP next-hop address.
  • Result: all prefixes learned from an external BGP neighbours use a single label.
传统BGP AS系统的设计要求 (Traditional BGP AS System Design Requirements)
  • All core routers are required to run BGP;
  • All core routers require full internet routing information (more than 100000 networks)to be able to forward IP packets between ISP1 & ISP2
    Note:OSPF can usually support 5000-10000 routes
 
基于MPLS网络的简化BGP设计 (Simplified BGP Network Design in MPLS-Based Networks)
 
  • Only Border routers are required to run BGP
  • Core routers run an IGP to learn about BGP next-hop address
  • Core routers run MPLS to forward labeled packets between Broader routers.
 
开始实验:
拓扑如上图,R4运行在ISP 1,AS100中,R6运行在ISP2,AS200中。其它Router都运行在AS10中。
 
Step 0:Basic Configuration
把Router的相关接口配上IP address,打开,如:
R4#
interface Loopback4
 ip address 4.4.4.4 255.255.255.255  //注意这里的loopback口都用32位。
!
interface Serial0/0
 ip address 24.0.0.4 255.255.255.0
 
Step 1: Run IGP (OSPF & EIGRP)
Configure IGP on all routers: EIGRP 100 on R4 & R2, OSPF 100 on R2, R1, R3, R5, EIGRP 200 on R5 & R6. Details as below:
R4#
router eigrp 100
 network 4.4.4.4 0.0.0.0
 network 24.0.0.0 0.0.0.255
 no auto-summary
R2#
router eigrp 100
 network 24.0.0.0 0.0.0.255
 no auto-summary
router ospf 10
 network 2.2.2.2 0.0.0.0 area 0
 network 12.0.0.0 0.0.0.255 area 0
R1#
router ospf 10
 network 1.1.1.1 0.0.0.0 area 0
 network 12.0.0.0 0.0.0.255 area 0
 network 13.0.0.0 0.0.0.255 area 0
R3#
router ospf 100
 network 3.3.3.3 0.0.0.0 area 0
 network 13.0.0.0 0.0.0.255 area 0
 network 35.0.0.0 0.0.0.255 area 0
R5#
router ospf 100
 network 3.3.3.3 0.0.0.0 area 0
 network 13.0.0.0 0.0.0.255 area 0
 network 35.0.0.0 0.0.0.255 area 0
router eigrp 200
 network 56.0.0.0 0.0.0.255
 no auto-summary
R6#
router eigrp 200
 network 6.6.6.6 0.0.0.0
 network 56.0.0.0 0.0.0.255
 no auto-summary
 
Step 2: Build a routing table
查看各Router上的信息,确保路由进程配置正确,路由表无误。
 
Step 3: Run MPLS
在R2, R1, R3, R5 上运行MPLS
Rx#      //x = 2,1,3,5
ip cef
mpls label protocol ldp  //Specify Label protocol
mpls ldp router-id lo0  //Specify MPLS Router ID
mpls label range x00 x99 //Specify Label Number range, x = 2,1,3,5
 
在接口上启动MPLS
int s0/0 (or s0/1 or f1/0)
 mpls ip
 
用traceroute命令检查MPLS对特定网段的Label交换
R2#
traceroute 5.5.5.5
 
Step 4: Run IBGP on Router 2 & 5
只在R2,R5上启动IBGP
R2#
router bgp 10
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 neighbor 5.5.5.5 remote-as 10
 neighbor 5.5.5.5 update-source Loopback2
 neighbor 5.5.5.5 next-hop-self  //如果没有, R5上收到的R2的路由不会被优化。
no auto-summary
R5#
router bgp 10
 no synchronization
 bgp router-id 5.5.5.5
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 10
 neighbor 2.2.2.2 update-source Loopback5
 neighbor 2.2.2.2 next-hop-self  //如果没有, R2上收到的R5的路由不会被优化。
no auto-summary

Step 5: Run EBGP on Routers, Advertise Networks
R4#
router bgp 100
 no synchronization
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 network 4.4.4.4 mask 255.255.255.255
 network 24.0.0.0 mask 255.255.255.0
 neighbor 24.0.0.2 remote-as 10
 no auto-summary
R2#
router bgp 10
neighbor 24.0.0.4 remote-as 100
R5#
router bgp 10
neighbor 56.0.0.6 remote-as 200
R6#
router bgp 200
 no synchronization
 bgp router-id 6.6.6.6
 bgp log-neighbor-changes
 network 6.6.6.6 mask 255.255.255.255
 network 56.0.0.0 mask 255.255.255.0
 neighbor 56.0.0.5 remote-as 10
 no auto-summary
 
检查BGP邻居关系和路由条目
R2#
sh ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 4.4.4.4/32       24.0.0.4                 0             0 100 i
*>i6.6.6.6/32       5.5.5.5                  0    100      0 200 i
r> 24.0.0.0/24      24.0.0.4                 0             0 100 i
*>i56.0.0.0/24      5.5.5.5                  0    100      0 200 i
 
Step 6: Traceroute Network from R4 to R6
R4#
traceroute 6.6.6.6
Note: At this moment, you can’t see the MPLS Label switching shown on routers
 
R4#
conf t
ip cef
int s0/0
mpls ip  //From now on, the Labels can be shown on R2, 1, 3
traceroute 6.6.6.6
Type escape sequence to abort.
Tracing the route to 6.6.6.6
  1 24.0.0.2 212 msec 20 msec 340 msec
  2 12.0.0.1 [MPLS: Label 105 Exp 0] 372 msec 116 msec 1012 msec
  3 13.0.0.3 [MPLS: Label 305 Exp 0] 456 msec 872 msec 448 msec
  4 35.0.0.5 368 msec 524 msec 264 msec
  5 56.0.0.6 [AS 200] 596 msec 904 msec 720 msec
可以看出,R2用R1的105 label 去往6.6.6.6/32的packet,而R1用R3的305 作label。到了R3,因为PHP的作用,label被pop掉,直接发给R5。这里可以用 show mpls ldp binding 和 show mpls forwarding-table 查看相关的LIB和LFIB。
 
Step7: Check Labels for different network segments
Add 6.6.6.66/32 & 6.6.6.67/32 to R6, and network to BGP 200.
R6#
in lo66
ip add 6.6.6.66 255.255.255.255
in l67
ip add 6.6.6.67 255.255.255.255
router bgp 200
 network 6.6.6.66 mask 255.255.255.255
 network 6.6.6.67 mask 255.255.255.255
 
Check routes of R6 from R4
R4#
sh ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 4.4.4.4/32       0.0.0.0                  0         32768 i
*> 6.6.6.6/32       24.0.0.2                               0 10 200 i
*> 6.6.6.66/32      24.0.0.2                               0 10 200 i
*> 6.6.6.67/32      24.0.0.2                               0 10 200 i
*> 24.0.0.0/24      0.0.0.0                  0         32768 i
*> 56.0.0.0/24      24.0.0.2                               0 10 200 i
 
Traceroute 6.6.6.66 & 6.6.6.67
traceroute 6.6.6.66
  1 24.0.0.2 284 msec 28 msec 216 msec
  2 12.0.0.1 [MPLS: Label 105 Exp 0] 616 msec 412 msec 304 msec
  3 13.0.0.3 [MPLS: Label 305 Exp 0] 336 msec 12 msec 1392 msec
  4 35.0.0.5 248 msec 512 msec 364 msec
  5 56.0.0.6 [AS 200] 1000 msec 868 msec 1000 msec

traceroute 6.6.6.67
  1 24.0.0.2 384 msec 80 msec 184 msec
  2 12.0.0.1 [MPLS: Label 105 Exp 0] 576 msec 648 msec 648 msec
  3 13.0.0.3 [MPLS: Label 305 Exp 0] 764 msec 228 msec 712 msec
  4 35.0.0.5 612 msec 372 msec 364 msec
  5 56.0.0.6 [AS 200] 440 msec 1044 msec 1156 msec
Label 105, 305 are used, 为何对不同网段,router会用一个label标识?
 
R2#
sh mpls forwarding
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop   
tag    tag or VC   or Tunnel Id      switched   interface             
200    Pop tag     1.1.1.1/32        0          Se0/0      point2point 
201    101         3.3.3.3/32        0          Se0/0      point2point 
203    Pop tag     13.0.0.0/24       0          Se0/0      point2point 
204    104         35.0.0.0/24       0          Se0/0      point2point 
205    105         5.5.5.5/32        0          Se0/0      point2point 
Ldp doesn't assign labels to BGP routes, but for IGP’s.
 
sh ip cef 6.6.6.6 detail
6.6.6.6/32, version 25, epoch 0, cached adjacency to Serial0/0
0 packets, 0 bytes
  tag information from 5.5.5.5/32, shared
    local tag: 205
    fast tag rewrite with Se0/0, point2point, tags imposed: {105}
  via 5.5.5.5, 0 dependencies, recursive
    next hop 12.0.0.1, Serial0/0 via 5.5.5.5/32
    valid cached adjacency
    tag rewrite with Se0/0, point2point, tags imposed: {105}
We can see that, R2 learns .6/32, .66/32 and .67/32 via BGP, and knows next hop is R5. So, R2 can use one label number 205 for all of these packets.
 
总结:MPLS的运作
R4#ping 6.6.6.6
DIP: 6.6.6.6  SIP: 24.0.0.1 >>>>>>>>IPv4 Packet
R2: BGP学过路由, 查这条BGP Next-hop 是 5.5.5.5, MPLS label=105,
       105   DIP: 6.6.6.6  SIP: 24.0.0.1  >>>>R1
R1: 305   DIP: 6.6.6.6  SIP: 24.0.0.1  >>>>R3
R3:          DIP: 6.6.6.6  SIP: 24.0.0.1  >>>>R5
R5: 收到原始IP Packet
Actually, MPLS is like a Tunnel using labels.

你可能感兴趣的:(职场,NetWork,休闲,BGP,MPLS)