MPLS实验二

拓扑

在这里插入图片描述

配置

  • R1、R2、R3、R4之间运行OSPF
  • R1与R5运行EBGP
  • R4与R6运行EBGP
  • R1与R4运行IBGP
  • R1、R2、R3、R4运行MPLS
R1#sh run 
Building configuration...

Current configuration : 2242 bytes
!
! Last configuration change at 00:38:27 UTC Thu Apr 20 2023
upgrade fpd auto
version 15.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
no ip icmp rate-limit unreachable
!
!
!
!
!
!
no ip domain lookup
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
mpls label range 100 199
!
!
!
!
!
!
!
!
!
!
redundancy
!
!
ip tcp synwait-time 5
! 
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Ethernet0/0
 no ip address
 shutdown
 duplex auto
!
interface GigabitEthernet0/0
 ip address 12.1.1.1 255.255.255.0
 duplex full
 speed 1000
 media-type gbic
 negotiation auto
 mpls ip
!
interface GigabitEthernet1/0
 ip address 15.1.1.1 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet3/0
 no ip address
 shutdown
 negotiation auto
!
interface Serial4/0
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/4
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/5
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/6
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/7
 no ip address
 shutdown
 serial restart-delay 0
!
!
router ospf 1
 router-id 1.1.1.1
 network 1.1.1.1 0.0.0.0 area 0
 network 12.1.1.1 0.0.0.0 area 0
 network 15.1.1.1 0.0.0.0 area 0
!
router bgp 1234
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor 15.1.1.5 remote-as 500
 neighbor 34.1.1.4 remote-as 1234
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
!
no cdp log mismatch duplex
!
!
mpls ldp router-id Loopback0
!
control-plane
!
!
!
mgcp profile default
!
!
!
gatekeeper
 shutdown
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line vty 0 4
 login
 transport input all
!
!
end

R2#sh run
Building configuration...

Current configuration : 2117 bytes
!
! Last configuration change at 07:26:53 UTC Mon Apr 17 2023
upgrade fpd auto
version 15.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
no ip icmp rate-limit unreachable
!
!
!
!
!
!
no ip domain lookup
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
mpls label range 200 299
!
!
!
!
!
!
!
!
!
!
redundancy
!
!
ip tcp synwait-time 5
! 
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Ethernet0/0
 no ip address
 shutdown
 duplex auto
!
interface GigabitEthernet0/0
 ip address 12.1.1.2 255.255.255.0
 duplex full
 speed 1000
 media-type gbic
 negotiation auto
 mpls ip
!
interface GigabitEthernet1/0
 ip address 23.1.1.2 255.255.255.0
 negotiation auto
 mpls ip
!
interface GigabitEthernet2/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet3/0
 no ip address
 shutdown
 negotiation auto
!
interface Serial4/0
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/4
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/5
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/6
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/7
 no ip address
 shutdown
 serial restart-delay 0
!
!
router ospf 1
 router-id 2.2.2.2
 network 2.2.2.2 0.0.0.0 area 0
 network 12.1.1.2 0.0.0.0 area 0
 network 23.1.1.2 0.0.0.0 area 0
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
!
no cdp log mismatch duplex
!
!
mpls ldp router-id Loopback0
!
control-plane
!
!
!
mgcp profile default
!
!
!
gatekeeper
 shutdown
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line vty 0 4
 login
 transport input all
!
!
end
R3#sh run 
Building configuration...

Current configuration : 2117 bytes
!
! Last configuration change at 06:50:37 UTC Mon Apr 17 2023
upgrade fpd auto
version 15.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R3
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
no ip icmp rate-limit unreachable
!
!
!
!
!
!
no ip domain lookup
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
mpls label range 300 399
!
!
!
!
!
!
!
!
!
!
redundancy
!
!
ip tcp synwait-time 5
! 
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface Ethernet0/0
 no ip address
 shutdown
 duplex auto
!
interface GigabitEthernet0/0
 ip address 23.1.1.3 255.255.255.0
 duplex full
 speed 1000
 media-type gbic
 negotiation auto
 mpls ip
!
interface GigabitEthernet1/0
 ip address 34.1.1.3 255.255.255.0
 negotiation auto
 mpls ip
!
interface GigabitEthernet2/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet3/0
 no ip address
 shutdown
 negotiation auto
!
interface Serial4/0
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/4
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/5
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/6
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/7
 no ip address
 shutdown
 serial restart-delay 0
!
!
router ospf 1
 router-id 3.3.3.3
 network 3.3.3.3 0.0.0.0 area 0
 network 23.1.1.3 0.0.0.0 area 0
 network 34.1.1.3 0.0.0.0 area 0
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
!
no cdp log mismatch duplex
!
!
mpls ldp router-id Loopback0
!
control-plane
!
!
!
mgcp profile default
!
!
!
gatekeeper
 shutdown
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line vty 0 4
 login
 transport input all
!
!
end
R4# sh run 
Building configuration...

Current configuration : 2242 bytes
!
! Last configuration change at 13:59:24 UTC Mon Apr 17 2023
upgrade fpd auto
version 15.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R4
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
no ip icmp rate-limit unreachable
!
!
!
!
!
!
no ip domain lookup
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
mpls label range 400 499
!
!
!
!
!
!
!
!
!
!
redundancy
!
!
ip tcp synwait-time 5
! 
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 4.4.4.4 255.255.255.255
!
interface Ethernet0/0
 no ip address
 shutdown
 duplex auto
!
interface GigabitEthernet0/0
 ip address 34.1.1.4 255.255.255.0
 duplex full
 speed 1000
 media-type gbic
 negotiation auto
 mpls ip
!
interface GigabitEthernet1/0
 ip address 46.1.1.4 255.255.255.0
 negotiation auto
!
interface GigabitEthernet2/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet3/0
 no ip address
 shutdown
 negotiation auto
!
interface Serial4/0
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/4
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/5
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/6
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/7
 no ip address
 shutdown
 serial restart-delay 0
!
!
router ospf 1
 router-id 4.4.4.4
 network 4.4.4.4 0.0.0.0 area 0
 network 34.1.1.4 0.0.0.0 area 0
 network 46.1.1.4 0.0.0.0 area 0
!
router bgp 1234
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 neighbor 12.1.1.1 remote-as 1234
 neighbor 46.1.1.6 remote-as 600
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
!
no cdp log mismatch duplex
!
!
mpls ldp router-id Loopback0
!
control-plane
!
!
!
mgcp profile default
!
!
!
gatekeeper
 shutdown
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line vty 0 4
 login
 transport input all
!
!
end
R5#sh run 
Building configuration...

Current configuration : 2074 bytes
!
! Last configuration change at 11:25:57 UTC Mon Apr 17 2023
upgrade fpd auto
version 15.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R5
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
no ip icmp rate-limit unreachable
!
!
!
!
!
!
no ip domain lookup
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
!
!
!
!
!
!
!
!
!
!
redundancy
!
!
ip tcp synwait-time 5
! 
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 5.5.5.5 255.255.255.255
!
interface Ethernet0/0
 no ip address
 shutdown
 duplex auto
!
interface GigabitEthernet0/0
 ip address 15.1.1.5 255.255.255.0
 duplex full
 speed 1000
 media-type gbic
 negotiation auto
!
interface GigabitEthernet1/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet2/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet3/0
 no ip address
 shutdown
 negotiation auto
!
interface Serial4/0
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/4
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/5
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/6
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/7
 no ip address
 shutdown
 serial restart-delay 0
!
!
router bgp 500
 bgp router-id 5.5.5.5
 bgp log-neighbor-changes
 network 5.5.5.5 mask 255.255.255.255
 neighbor 15.1.1.1 remote-as 1234
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
ip route 0.0.0.0 0.0.0.0 15.1.1.1
!
no cdp log mismatch duplex
!
!
!
control-plane
!
!
!
mgcp profile default
!
!
!
gatekeeper
 shutdown
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line vty 0 4
 login
 transport input all
!
!
end
R6#sh run 
Building configuration...

Current configuration : 2011 bytes
!
! Last configuration change at 14:53:29 UTC Mon Apr 17 2023
upgrade fpd auto
version 15.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R6
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
no ip icmp rate-limit unreachable
!
!
!
!
!
!
no ip domain lookup
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
!
!
!
!
!
!
!
!
!
!
redundancy
!
!
ip tcp synwait-time 5
! 
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 6.6.6.6 255.255.255.255
!
interface Ethernet0/0
 no ip address
 shutdown
 duplex auto
!
interface GigabitEthernet0/0
 ip address 46.1.1.6 255.255.255.0
 duplex full
 speed 1000
 media-type gbic
 negotiation auto
 mpls ip
!
interface GigabitEthernet1/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet2/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet3/0
 no ip address
 shutdown
 negotiation auto
!
interface Serial4/0
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/1
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/2
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/3
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/4
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/5
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/6
 no ip address
 shutdown
 serial restart-delay 0
!
interface Serial4/7
 no ip address
 shutdown
 serial restart-delay 0
!
!
router bgp 600
 bgp router-id 6.6.6.6
 bgp log-neighbor-changes
 neighbor 46.1.1.4 remote-as 1234
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
!
no cdp log mismatch duplex
!
!
!
control-plane
!
!
!
mgcp profile default
!
!
!
gatekeeper
 shutdown
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
 stopbits 1
line vty 0 4
 login
 transport input all
!
!
end

测试

R6#traceroute 5.5.5.5
Type escape sequence to abort.
Tracing the route to 5.5.5.5
VRF info: (vrf in name/id, vrf out name/id)
  1 46.1.1.4 56 msec 44 msec 48 msec
  2 34.1.1.3 [MPLS: Label 304 Exp 0] 120 msec 92 msec 84 msec
  3 23.1.1.2 [MPLS: Label 203 Exp 0] 88 msec 68 msec 64 msec
  4 12.1.1.1 96 msec 100 msec 88 msec
  5 15.1.1.5 100 msec 112 msec 104 msec

R6上查看路由,下一跳是R4

R6#sh ip route 
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      5.0.0.0/32 is subnetted, 1 subnets
B        5.5.5.5 [20/0] via 46.1.1.4, 13:06:47
      6.0.0.0/32 is subnetted, 1 subnets
C        6.6.6.6 is directly connected, Loopback0
      46.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        46.1.1.0/24 is directly connected, GigabitEthernet0/0
L        46.1.1.6/32 is directly connected, GigabitEthernet0/0

R4上查看cef表,发现5.5.5.5/32的路由带的mpls label为304,其实通过sh mpls ldp bindings ,发现304标签是R3为15.1.1.0/24压入的标签,因为mpls不为bgp路由分配标签

R4# sh ip cef 5.5.5.5 detail 
5.5.5.5/32, epoch 0, flags rib only nolabel, rib defined all labels
  recursive via 15.1.1.5
    recursive via 15.1.1.0/24
      nexthop 34.1.1.3 GigabitEthernet0/0 label 304
R4#sh mpls ldp bindings 
  lib entry: 1.1.1.1/32, rev 2
        local binding:  label: 400
        remote binding: lsr: 3.3.3.3:0, label: 300
  lib entry: 2.2.2.2/32, rev 4
        local binding:  label: 401
        remote binding: lsr: 3.3.3.3:0, label: 301
  lib entry: 3.3.3.3/32, rev 6
        local binding:  label: 402
        remote binding: lsr: 3.3.3.3:0, label: imp-null
  lib entry: 4.4.4.4/32, rev 8
        local binding:  label: imp-null
        remote binding: lsr: 3.3.3.3:0, label: 302
  lib entry: 12.1.1.0/24, rev 10
        local binding:  label: 403
        remote binding: lsr: 3.3.3.3:0, label: 303
  lib entry: 15.1.1.0/24, rev 12
        local binding:  label: 404
        remote binding: lsr: 3.3.3.3:0, label: 304
  lib entry: 23.1.1.0/24, rev 14
        local binding:  label: 405
        remote binding: lsr: 3.3.3.3:0, label: imp-null
  lib entry: 34.1.1.0/24, rev 16
        local binding:  label: imp-null
        remote binding: lsr: 3.3.3.3:0, label: imp-null
  lib entry: 46.1.1.0/24, rev 18
        local binding:  label: imp-null
        remote binding: lsr: 3.3.3.3:0, label: 305     
R4#sh mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop    
Label      Label      or Tunnel Id     Switched      interface              
400        300        1.1.1.1/32       0             Gi0/0      34.1.1.3    
401        301        2.2.2.2/32       0             Gi0/0      34.1.1.3    
402        Pop Label  3.3.3.3/32       0             Gi0/0      34.1.1.3    
403        303        12.1.1.0/24      0             Gi0/0      34.1.1.3    
404        304        15.1.1.0/24      0             Gi0/0      34.1.1.3    
405        Pop Label  23.1.1.0/24      0             Gi0/0      34.1.1.3   
R3#sh mpls forwarding-table 
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop    
Label      Label      or Tunnel Id     Switched      interface              
300        200        1.1.1.1/32       0             Gi0/0      23.1.1.2    
301        Pop Label  2.2.2.2/32       0             Gi0/0      23.1.1.2    
302        Pop Label  4.4.4.4/32       0             Gi1/0      34.1.1.4    
303        Pop Label  12.1.1.0/24      24647         Gi0/0      23.1.1.2    
304        203        15.1.1.0/24      10344         Gi0/0      23.1.1.2    
305        Pop Label  46.1.1.0/24      12642         Gi1/0      34.1.1.4
R2#sh mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop    
Label      Label      or Tunnel Id     Switched      interface              
200        Pop Label  1.1.1.1/32       0             Gi0/0      12.1.1.1    
201        Pop Label  3.3.3.3/32       0             Gi1/0      23.1.1.3    
202        302        4.4.4.4/32       0             Gi1/0      23.1.1.3    
203        Pop Label  15.1.1.0/24      11682         Gi0/0      12.1.1.1    
204        Pop Label  34.1.1.0/24      24622         Gi1/0      23.1.1.3    
205        305        46.1.1.0/24      11720         Gi1/0      23.1.1.3 

R1是15.1.1.0/24 的直连路由,所以压入imp-null隐式空标签,传给下游R2实现次末跳弹出

R1#sh mpls ldp bindings 
  lib entry: 1.1.1.1/32, rev 2
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: 200
  lib entry: 2.2.2.2/32, rev 4
        local binding:  label: 100
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 3.3.3.3/32, rev 6
        local binding:  label: 101
        remote binding: lsr: 2.2.2.2:0, label: 201
  lib entry: 4.4.4.4/32, rev 8
        local binding:  label: 102
        remote binding: lsr: 2.2.2.2:0, label: 202
  lib entry: 12.1.1.0/24, rev 10
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 15.1.1.0/24, rev 12
        local binding:  label: imp-null
        remote binding: lsr: 2.2.2.2:0, label: 203
  lib entry: 23.1.1.0/24, rev 14
        local binding:  label: 103
        remote binding: lsr: 2.2.2.2:0, label: imp-null
  lib entry: 34.1.1.0/24, rev 16
        local binding:  label: 104
        remote binding: lsr: 2.2.2.2:0, label: 204
  lib entry: 46.1.1.0/24, rev 18
        local binding:  label: 105
        remote binding: lsr: 2.2.2.2:0, label: 205
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值