1、MPLS骨干网络运行OSPF使得学习到骨干网络的所有路由
[p1]dis ospf peer brief
OSPF Process 1 with Router ID 3.3.3.3
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 4.4.4.4 Full
0.0.0.0 GigabitEthernet0/0/1 2.2.2.2 Full
----------------------------------------------------------------------------
2、MPLS骨干网络中激活MPLS,并激活LDP,建立LDP对等体
[PE1]dis mpls lsp
-------------------------------------------------------------------------------
LSP Information: LDP LSP
-------------------------------------------------------------------------------
FEC In/Out Label In/Out IF Vrf Name
2.2.2.2/32 3/NULL -/-
3.3.3.3/32 NULL/3 -/GE0/0/0
3.3.3.3/32 1024/3 -/GE0/0/0
4.4.4.4/32 NULL/1025 -/GE0/0/0
4.4.4.4/32 1025/1025 -/GE0/0/0
5.5.5.5/32 NULL/1026 -/GE0/0/0
5.5.5.5/32 1026/1026 -/GE0/0/0
3、在R2及R5上创建VRF,将连接CE的接口分配给VRF,R2和R1运行BGP,R5和R6运行BGP
在R5上看
[PE2]dis ip routing-table vpn-instance A
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: A
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.0.0/24 Direct 0 0 D 172.16.0.3 GigabitEthernet
0/0/0
172.16.0.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
172.16.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
172.16.2.2/32 OSPF 10 1 D 172.16.0.4 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
在R2上看
<PE1>dis ip routing-table vpn-instance A
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: A
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.0.0/30 Direct 0 0 D 172.16.0.1 GigabitEthernet
0/0/1
172.16.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
172.16.0.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
172.16.1.0/24 EBGP 255 0 D 172.16.0.2 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
4、在R2-R5上建立MP_BGP
[PE2-bgp-af-vpnv4]dis bgp vpnv4 all peer
BGP local router ID : 5.5.5.5
Local AS number : 2
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
2.2.2.2 4 2 3 2 0 00:00:01 Established
5、宣告路由
[Huawei-bgp]dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 172.16.1.0/24 0.0.0.0 0 0 i
*> 172.16.2.0/24 172.16.0.1 0 2 3i
验证:[Huawei-bgp]ping -a 172.16.1.1 172.16.2.2
PING 172.16.2.2: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.2: bytes=56 Sequence=1 ttl=251 time=40 ms
Reply from 172.16.2.2: bytes=56 Sequence=2 ttl=251 time=30 ms
Reply from 172.16.2.2: bytes=56 Sequence=3 ttl=251 time=30 ms
Reply from 172.16.2.2: bytes=56 Sequence=4 ttl=251 time=40 ms
Reply from 172.16.2.2: bytes=56 Sequence=5 ttl=251 time=40 ms
R2配置:
#
ip vpn-instance A
ipv4-family
route-distinguisher 1:1
vpn-target 1:1 export-extcommunity
vpn-target 1:1 import-extcommunity
#
mpls lsr-id 2.2.2.2
mpls
#
mpls ldp
#
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip address 10.0.23.2 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip binding vpn-instance A
ip address 172.16.0.1 255.255.255.252
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
bgp 2
router-id 2.2.2.2
peer 5.5.5.5 as-number 2
peer 5.5.5.5 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 5.5.5.5 enable
peer 5.5.5.5 next-hop-local
#
ipv4-family vpnv4
policy vpn-target
peer 5.5.5.5 enable
#
ipv4-family vpn-instance A
router-id 172.16.0.1
peer 172.16.0.2 as-number 1
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 10.0.23.0 0.0.0.255
#
R3配置:
#
ip vpn-instance A
ipv4-family
route-distinguisher 1:1
vpn-target 1:1 export-extcommunity
vpn-target 1:1 import-extcommunity
#
mpls lsr-id 5.5.5.5
mpls
#
mpls ldp
#
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
ip binding vpn-instance A
ip address 172.16.0.3 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.0.45.5 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
ip address 5.5.5.5 255.255.255.255
#
bgp 2
router-id 5.5.5.5
peer 2.2.2.2 as-number 2
peer 2.2.2.2 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 2.2.2.2 enable
peer 2.2.2.2 next-hop-local
#
ipv4-family vpnv4
policy vpn-target
peer 2.2.2.2 enable
#
ipv4-family vpn-instance A
peer 172.16.0.4 as-number 3
#
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 5.5.5.5 0.0.0.0
network 10.0.45.0 0.0.0.255
#