1. 程式人生 > 實用技巧 >【思科***】BGP MPLS-***基本部署例項

【思科***】BGP MPLS-***基本部署例項

實驗拓撲:

wKioL1Rlf0bzdXQ2AAGmxFT_JBM682.jpg

實驗需求:如圖,R1,R2,R3為公網路由器,屬於AS65001。R4,R6為A公司的總公司和子公司出口路由器,R5,R7為B公司的總公司和子公司的出口路由器。運營商為R4,R5連線R1的網段均部署為私網網段172.16.40.0/24 ,為R6,R7連線R3的網段部署為172.16.60.0/24和172.16.70.0/24 。

要求使A公司的總公司(40.1)能與子公司出口路由器的內網網段(60.1)通訊,B公司的總公司(40.1)能與子公司出口路由器的內網網段(70.1)通訊。

實驗步驟:

  1. 首先進行基本配置。(R1,R3的下行口一會再配)

R1:

f0/0:12.0.0.1/24

l0:1.1.1.1/32

R2:

f0/0:12.0.0.2/24

f0/1:23.0.0.2/24

l0:2.2.2.2/32

R3

f0/0:23.0.0.3/24

l0:3.3.3.3/32

R4

f0/0:172.16.40.2/24

l0:192.168.40.1/24

R5

f0/0:172.16.40.2/24

l0:192.168.40.1/24

R6

f0/0:172.16.60.2/24

l0:192.168.60.1/24

R7

f0/0:172.16.70.2/24

l0:192.168.70.1/24

首先在R1,R2,R3上執行ospf協議。

R1

router ospf 1
router-id 1.1.1.1
network 1.1.1.1 0.0.0.0 area 0
network 12.0.0.0 0.0.0.255 area 0
!

R2

router ospf 1
router-id 2.2.2.2

network 2.2.2.2 0.0.0.0 area 0
network 12.0.0.0 0.0.0.255 area 0
network 23.0.0.0 0.0.0.255 area 0
!

R3

router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 23.0.0.0 0.0.0.255 area 0
!

測試下連通性

R1#p 3.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/42/64 ms

2.執行mpls-***,建立vrf路由表

建立A公司的vrf表***a,建立B公司的vrf表***b

R1

ip vrf ***a
rd 100:1
route-target export 100:1
route-target import 100:1
!


ip vrf ***b
rd 200:1
route-target export 200:1
route-target import 200:1
!

將下行口分別放入***a,***b

interface FastEthernet0/1
ip vrf forwarding ***a
ip address 172.16.40.1 255.255.255.0

!
interface FastEthernet1/0
ip vrf forwarding ***b
ip address 172.16.40.1 255.255.255.0
!

在R4,R5上做預設指向R1, R1上做靜態往下指

R4

ip route 0.0.0.0 0.0.0.0 172.16.40.1
!

R5

ip route 0.0.0.0 0.0.0.0 172.16.40.1
!

R1做靜態時要關聯vrf表

R1

ip route vrf ***a 192.168.40.0 255.255.255.0 172.16.40.2
ip route vrf ***b 192.168.40.0 255.255.255.0 172.16.40.2
!

測試下連通性

R1#p vrf ***a 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.40.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/20/24 ms

R3與R1做類似配置

R3

ip vrf ***a
rd 100:1
route-target export 100:1
route-target import 100:1
!


ip vrf ***b
rd 200:1
route-target export 200:1
route-target import 200:1
!

interface FastEthernet0/1
ip vrf forwarding ***a
ip address 172.16.60.1 255.255.255.0
!


interface FastEthernet1/0
ip vrf forwarding ***b
ip address 172.16.70.1 255.255.255.0
!

R3,R6,R7執行ripv2協議

R6

router rip
version 2
network 172.16.60.0
network 192.168.60.0
no auto-summary
!

R7

router rip
version 2
network 172.16.70.0
network 192.168.70.0
no auto-summary

R3執行ripv2時要關聯vrf路由表

R3

router rip
!
address-family ipv4 vrf ***b
network 172.16.60.0
no auto-summary
version 2
exit-address-family
!


address-family ipv4 vrf ***a
network 172.16.70.0
no auto-summary
version 2

測試下連通性

R3#p vrf ***a 192.168.60.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.60.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/23/56 ms

現在私網網段已經搞定了。

3.在R1,R3上執行MP-BGP協議,建立IBGP鄰居。

R1

router bgp 65001
bgp router-id 1.1.1.1
neighbor 3.3.3.3 remote-as 65001
neighbor 3.3.3.3 update-source Loopback0
!


啟用MP-BGP鄰居

address-family ***v4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community extended
exit-address-family
!

R3

router bgp 65001
bgp router-id 3.3.3.3
neighbor 1.1.1.1 remote-as 65001
neighbor 1.1.1.1 update-source Loopback0
!

address-family ***v4
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 send-community extended
exit-address-family
!

在R1的BGP上釋出兩條192.168.40.0/24路由,這裡採用直接network 和重發布兩種方法。

R1

router bgp 65001

address-family ipv4 vrf ***a
network 192.168.60.0
exit-address-family

address-family ipv4 vrf ***b
redistributestatic metric 20

exit-address-family
!


在R3的BGP上,將ripv2重發布進bgp,同時也要將bgp協議重發布進ripv2,使得回程可達。

R3

router bgp 65001

address-family ipv4 vrf ***a
redistribute rip metric 20

exit-address-family

router bgp 65001

address-family ipv4 vrf ***b
redistribute rip metric 20

exit-address-family

router rip

address-family ipv4 vrf ***a
redistribute bgp 65001 metric 3

!

router rip

address-family ipv4 vrf ***b
redistribute bgp 65001 metric 3

!

4.別忘記R2並沒有執行BGP,並無私網路由,此時會造成路由黑洞,因此,在R1,R2,R3上可以執行ldp協議來解決。

R1

interface FastEthernet0/0
mpls ip
!

R2

interface FastEthernet0/0
mpls ip
!
interface FastEthernet0/1
mpls ip
!

R3

interface FastEthernet0/0
mpls ip
!

檢視ldp鄰居是否建立

R2

R2#show mpls ldp neighbor


Peer LDP Ident: 1.1.1.1:0; Local LDP Ident 2.2.2.2:0
TCP connection: 1.1.1.1.646 - 2.2.2.2.21318
State: Oper; Msgs sent/rcvd: 97/98; Downstream
Up time: 01:18:42
LDP discovery sources:
FastEthernet0/0, Src IP addr: 12.0.0.1
Addresses bound to peer LDP Ident:
12.0.0.1 1.1.1.1


Peer LDP Ident: 3.3.3.3:0; Local LDP Ident 2.2.2.2:0
TCP connection: 3.3.3.3.14076 - 2.2.2.2.646
State: Oper; Msgs sent/rcvd: 99/97; Downstream
Up time: 01:18:41
LDP discovery sources:
FastEthernet0/1, Src IP addr: 23.0.0.3
Addresses bound to peer LDP Ident:
23.0.0.3 3.3.3.3

沒問題,在R1,R3上檢視是否學習到對方的私網路由

R1

R1#show ip bgp ***v4 vrf ***a
BGP table version is 9, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 100:1 (default for vrf ***a)
*> 192.168.40.0 172.16.40.2 0 32768 i
*>i192.168.60.0 3.3.3.3 1 100 0 i

R1#show ip bgp ***v4 vrf ***b
BGP table version is 9, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 200:1 (default for vrf ***b)
*> 192.168.40.0 172.16.40.2 0 32768 i
*>i192.168.70.0 3.3.3.3 1 100 0 i

R3
R3#show ip bgp ***v4 vrf ***a
BGP table version is 9, local router ID is 3.3.3.3
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 100:1 (default for vrf ***a)
*>i192.168.40.0 1.1.1.1 0 100 0 i
*> 192.168.60.0 172.16.60.2 1 32768 i


R3#show ip bgp ***v4 vrf ***b
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 200:1 (default for vrf ***b)
*>i192.168.40.0 1.1.1.1 0 100 0 i
*> 192.168.70.0 172.16.70.2 1 32768 i

可以發現已經互相學習到了

最後進行連通性測試

R4

R4#p 192.168.60.1 source 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.60.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.40.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/78/116 ms
R4#

R5

R5#p 192.168.70.1 source 192.168.40.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.70.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.40.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/92/128 ms

可以通訊了,實驗結束。

本文出自 “NE之路” 部落格,請務必保留此出處http://332162926.blog.51cto.com/8831013/1576426


轉載於:https://blog.51cto.com/wanglei1024/1922148