PE-CE间路由协议
拓扑
接口配置
R1
Router>en
Router#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1
R1(config)#interface Loopback0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#interface Fa0/0
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R2
Router>en
Router#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#interface Loopback0
R2(config-if)#ip address 2.2.2.2 255.255.255.255
R2(config-if)#interface Fa0/0
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface Fa0/1
R2(config-if)#ip address 23.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R3
Router>en
Router#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R3
R3(config)#interface Loopback0
R3(config-if)#ip address 3.3.3.3 255.255.255.255
R3(config-if)#interface Fa0/0
R3(config-if)#ip address 23.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#interface Fa0/1
R3(config-if)#ip address 34.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R4
Router>en
Router#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R4
R4(config)#interface Loopback0
R4(config-if)#ip address 4.4.4.4 255.255.255.255
R4(config-if)#interface Fa0/0
R4(config-if)#ip address 45.1.1.4 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#interface Fa0/1
R4(config-if)#ip address 34.1.1.4 255.255.255.0
R4(config-if)#no shutdown
R5
Router>en
Router#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R5
R5(config)#interface Loopback0
R5(config-if)#ip address 192.168.5.5 255.255.255.0
R5(config-if)#interface Fa0/0
R5(config-if)#ip address 45.1.1.5 255.255.255.0
R5(config-if)#no shutdown
MPLS域配置eigrp
MPLS域之间配置eigrp进行保证环回口可以通讯
R2
R2(config)#router eigrp 100
R2(config-router)#no auto-summary
R2(config-router)#network 2.2.2.2 0.0.0.0
R2(config-router)#network 23.1.1.2 0.0.0.0
R3
R3(config)#router eigrp 100
R3(config-router)#no auto-summary
R3(config-router)#network 23.1.1.3 0.0.0.0
R3(config-router)#network 3.3.3.3 0.0.0.0
R3(config-router)#network 34.1.1.3 0.0.0.0
R4
R4(config)#router eigrp 100
R4(config-router)#no auto-summary
R4(config-router)#network 34.1.1.4 0.0.0.0
R4(config-router)#network 4.4.4.4 0.0.0.0
配置MPLS域
R2
R2(config)#ip cef
R2(config)#mpls ip
R2(config)#mpls label protocol ldp
R2(config)#mpls ldp router-id loopback 0
R2(config)#interface FastEthernet 0/1
R2(config-if)#mpls ip
R3
R3(config)#ip cef
R3(config)#mpls ip
R3(config)#mpls label protocol ldp
R3(config)#mpls ldp router-id loopback 0
R3(config)#int fastEthernet 0/0
R3(config-if)#mpls ip
R3(config-if)#int fastEthernet 0/1
R3(config-if)#mpls ip
R4
R4(config)#ip cef
R4(config)#mpls ip
R4(config)#mpls label protocol ldp
R4(config)#mpls ldp router-id loopback 0
R4(config)#int fa0/1
R4(config-if)#mpls ip
查看mpls域配置情况
R2
R2#show mpls interfaces
Interface IP Tunnel Operational
FastEthernet0/1 Yes (ldp) No Yes
R2#show mpls ldp neighbor
Peer LDP Ident: 3.3.3.3:0; Local LDP Ident 2.2.2.2:0
TCP connection: 3.3.3.3.57787 - 2.2.2.2.646
State: Oper; Msgs sent/rcvd: 17/16; Downstream
Up time: 00:07:26
LDP discovery sources:
FastEthernet0/1, Src IP addr: 23.1.1.3
Addresses bound to peer LDP Ident:
23.1.1.3 34.1.1.3 3.3.3.3
R2#show mpls ldp bindings
tib entry: 2.2.2.2/32, rev 4
local binding: tag: imp-null
remote binding: tsr: 3.3.3.3:0, tag: 16
tib entry: 3.3.3.3/32, rev 6
local binding: tag: 17
remote binding: tsr: 3.3.3.3:0, tag: imp-null
tib entry: 4.4.4.4/32, rev 8
local binding: tag: 18
remote binding: tsr: 3.3.3.3:0, tag: 17
tib entry: 12.1.1.0/24, rev 12
local binding: tag: imp-null
tib entry: 23.1.1.0/24, rev 10
local binding: tag: imp-null
remote binding: tsr: 3.3.3.3:0, tag: imp-null
tib entry: 34.1.1.0/24, rev 2
local binding: tag: 16
remote binding: tsr: 3.3.3.3:0, tag: imp-null
R2#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 34.1.1.0/24 0 Fa0/1 23.1.1.3
17 Pop tag 3.3.3.3/32 0 Fa0/1 23.1.1.3
18 17 4.4.4.4/32 0 Fa0/1 23.1.1.3
R3
R3#show mpls interfaces
Interface IP Tunnel Operational
FastEthernet0/0 Yes (ldp) No Yes
FastEthernet0/1 Yes (ldp) No Yes
R3#show mpls ldp neighbor
Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 3.3.3.3:0
TCP connection: 2.2.2.2.646 - 3.3.3.3.57787
State: Oper; Msgs sent/rcvd: 16/17; Downstream
Up time: 00:07:05
LDP discovery sources:
FastEthernet0/0, Src IP addr: 23.1.1.2
Addresses bound to peer LDP Ident:
12.1.1.2 23.1.1.2 2.2.2.2
Peer LDP Ident: 4.4.4.4:0; Local LDP Ident 3.3.3.3:0
TCP connection: 4.4.4.4.63273 - 3.3.3.3.646
State: Oper; Msgs sent/rcvd: 14/15; Downstream
Up time: 00:05:20
LDP discovery sources:
FastEthernet0/1, Src IP addr: 34.1.1.4
Addresses bound to peer LDP Ident:
45.1.1.4 34.1.1.4 4.4.4.4
R3#show mpls ldp bindings
tib entry: 2.2.2.2/32, rev 4
local binding: tag: 16
remote binding: tsr: 2.2.2.2:0, tag: imp-null
remote binding: tsr: 4.4.4.4:0, tag: 16
tib entry: 3.3.3.3/32, rev 6
local binding: tag: imp-null
remote binding: tsr: 2.2.2.2:0, tag: 17
remote binding: tsr: 4.4.4.4:0, tag: 17
tib entry: 4.4.4.4/32, rev 8
local binding: tag: 17
remote binding: tsr: 2.2.2.2:0, tag: 18
remote binding: tsr: 4.4.4.4:0, tag: imp-null
tib entry: 12.1.1.0/24, rev 11
remote binding: tsr: 2.2.2.2:0, tag: imp-null
tib entry: 23.1.1.0/24, rev 10
local binding: tag: imp-null
remote binding: tsr: 2.2.2.2:0, tag: imp-null
remote binding: tsr: 4.4.4.4:0, tag: 18
tib entry: 34.1.1.0/24, rev 2
local binding: tag: imp-null
remote binding: tsr: 2.2.2.2:0, tag: 16
remote binding: tsr: 4.4.4.4:0, tag: imp-null
tib entry: 45.1.1.0/24, rev 12
remote binding: tsr: 4.4.4.4:0, tag: imp-null
R3#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 2.2.2.2/32 0 Fa0/0 23.1.1.2
17 Pop tag 4.4.4.4/32 0 Fa0/1 34.1.1.4
R4
R4#show mpls interfaces
Interface IP Tunnel Operational
FastEthernet0/1 Yes (ldp) No Yes
R4#show mpls ldp neighbor
Peer LDP Ident: 3.3.3.3:0; Local LDP Ident 4.4.4.4:0
TCP connection: 3.3.3.3.646 - 4.4.4.4.63273
State: Oper; Msgs sent/rcvd: 14/13; Downstream
Up time: 00:05:03
LDP discovery sources:
FastEthernet0/1, Src IP addr: 34.1.1.3
Addresses bound to peer LDP Ident:
23.1.1.3 34.1.1.3 3.3.3.3
R4#show mpls ldp bindings
tib entry: 2.2.2.2/32, rev 4
local binding: tag: 16
remote binding: tsr: 3.3.3.3:0, tag: 16
tib entry: 3.3.3.3/32, rev 6
local binding: tag: 17
remote binding: tsr: 3.3.3.3:0, tag: imp-null
tib entry: 4.4.4.4/32, rev 8
local binding: tag: imp-null
remote binding: tsr: 3.3.3.3:0, tag: 17
tib entry: 23.1.1.0/24, rev 10
local binding: tag: 18
remote binding: tsr: 3.3.3.3:0, tag: imp-null
tib entry: 34.1.1.0/24, rev 2
local binding: tag: imp-null
remote binding: tsr: 3.3.3.3:0, tag: imp-null
tib entry: 45.1.1.0/24, rev 12
local binding: tag: imp-null
R4# show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 16 2.2.2.2/32 0 Fa0/1 34.1.1.3
17 Pop tag 3.3.3.3/32 0 Fa0/1 34.1.1.3
18 Pop tag 23.1.1.0/24 0 Fa0/1 34.1.1.3
PE设备配置VRF
配置RD:RT信息
R2
R2(config)#ip vrf SITE1
R2(config-vrf)#rd 1:1
R2(config-vrf)#route-target Export 100:1
R2(config-vrf)#route-target import 200:1
R2(config-vrf)#exit
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip vrf forwarding SITE1
% Interface FastEthernet0/0 IP address 12.1.1.2 removed due to enabling VRF SITE1 //由于地址被删除了需要重新配置
R2(config-if)#ip add 12.1.1.2 255.255.255.0
R4
R4(config)#ip vrf SITE2
R4(config-vrf)#rd 2:2
R4(config-vrf)#route-target export 200:1
R4(config-vrf)#route-target import 100:1
R4(config-vrf)#exit
R4(config)#int fastEthernet 0/0
R4(config-if)#ip vrf forwarding SITE2
R4(config-if)#ip add 45.1.1.4 255.255.255.0
PE-CE间路由协议-Static
配置PE-CE路由(static)
R2
R2(config)#ip route vrf SITE1 192.168.1.0 255.255.255.0 12.1.1.1
R4
R4(config)#ip route vrf SITE2 192.168.5.0 255.255.255.0 45.1.1.5
R1
R1(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.2
R5
R5(config)#ip route 0.0.0.0 0.0.0.0 45.1.1.4
查看路由情况
R2
R2#show ip route vrf SITE1
Routing Table: SITE1
Codes: 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
Gateway of last resort is not set
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
S 192.168.1.0/24 [1/0] via 12.1.1.1
R4
R4#show ip route vrf SITE2
Routing Table: SITE2
Codes: 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
Gateway of last resort is not set
S 192.168.5.0/24 [1/0] via 45.1.1.5
45.0.0.0/24 is subnetted, 1 subnets
C 45.1.1.0 is directly connected, FastEthernet0/0
配置VPNV4
R2
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no bgp default ipv4-unicast
R2(config-router)#neighbor 4.4.4.4 remote-as 100
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#address-family vpnv4
R2(config-router-af)#neighbor 4.4.4.4 activate
R4
R4(config)#router bgp 100
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#neighbor 2.2.2.2 remote-as 100
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate
查看邻居状态
####R2
R2#show ip bgp vpnv4 all summary
BGP router identifier 2.2.2.2, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4 4 100 26 26 1 0 0 00:22:32 0
R4
R4#show ip bgp vpnv4 all summary
BGP router identifier 4.4.4.4, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 100 26 26 1 0 0 00:22:28 0
重分布
R2
R2(config)#router bgp 100
R2(config-router)#address-family ipv4 vrf SITE1 //这个是自己生成的
R2(config-router-af)#redistribute static
R4
R4(config)#router bgp 100
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#redistribute static
查看重分布后的路由情况
R2
R2#show ip route vrf SITE1
Routing Table: SITE1
Codes: 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
Gateway of last resort is not set
B 192.168.5.0/24 [200/0] via 4.4.4.4, 00:02:02
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
S 192.168.1.0/24 [1/0] via 12.1.1.1
R4
R4#show ip route vrf SITE2
Routing Table: SITE2
Codes: 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
Gateway of last resort is not set
S 192.168.5.0/24 [1/0] via 45.1.1.5
B 192.168.1.0/24 [200/0] via 2.2.2.2, 00:01:34
45.0.0.0/24 is subnetted, 1 subnets
C 45.1.1.0 is directly connected, FastEthernet0/0
vpn测试
R1
R1#ping 192.168.5.5 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.5.5, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/63/88 ms
R5
R5#ping 192.168.1.1 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 124/149/172 ms
标签情况
R2#show ip bgp vpnv4 all labels //查看私网标签
Network Next Hop In label/Out label
Route Distinguisher: 1:1 (SITE1)
192.168.1.0 12.1.1.1 19/nolabel //这里是19是
192.168.5.0 4.4.4.4 nolabel/19
Route Distinguisher: 2:2
192.168.5.0 4.4.4.4 nolabel/19 //这里是4.4.4.4送过来的
R4#show ip bgp vpnv4 all labels
Network Next Hop In label/Out label
Route Distinguisher: 1:1
192.168.1.0 2.2.2.2 nolabel/19
Route Distinguisher: 2:2 (SITE2)
192.168.1.0 2.2.2.2 nolabel/19
192.168.5.0 45.1.1.5 19/nolabel
R3#show mpls forwarding-table //查看公网标签
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 2.2.2.2/32 3208 Fa0/0 23.1.1.2
17 Pop tag 4.4.4.4/32 7704 Fa0/1 34.1.1.4
PE-CE间路由协议-OSPF
配置PE-CE路由(ospf)
R2
R2(config)#router ospf 1 vrf SITE1
R2(config-router)#network 12.1.1.2 0.0.0.0 area 1
R4
R4(config)#router ospf 1 vrf SITE2
R4(config-router)#network 45.1.1.4 0.0.0.0 area 1
R1
R1(config)#router ospf 1
R1(config-router)# network 192.168.1.1 0.0.0.0 area 1
R1(config-router)# network 12.1.1.1 0.0.0.0 area 1
R5
R5(config)#router ospf 1
R5(config-router)#network 192.168.5.5 0.0.0.0 area 1
R5(config-router)# network 45.1.1.5 0.0.0.0 area 1
查看路由情况
R2
R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.1.1 1 FULL/DR 00:00:33 12.1.1.1 FastEthernet0/0
R4
R4#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.5.5 1 FULL/DR 00:00:37 45.1.1.5 FastEthernet0/0
配置VPNV4
R2
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no bgp default ipv4-unicast
R2(config-router)#neighbor 4.4.4.4 remote-as 100
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#address-family vpnv4
R2(config-router-af)#neighbor 4.4.4.4 activate
R4
R4(config)#router bgp 100
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#neighbor 2.2.2.2 remote-as 100
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate
查看邻居状态
R2
R2#show ip bgp vpnv4 all summary
BGP router identifier 2.2.2.2, local AS number 100
BGP table version is 8, main routing table version 8
3 network entries using 420 bytes of memory
3 path entries using 204 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
2 BGP extended community entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 1076 total bytes of memory
BGP activity 4/1 prefixes, 4/1 paths, scan interval 15 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4 4 100 68 67 8 0 0 00:37:13 1
R4
R4#show ip bgp vpnv4 all summary
BGP router identifier 4.4.4.4, local AS number 100
BGP table version is 5, main routing table version 5
3 network entries using 420 bytes of memory
3 path entries using 204 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
2 BGP extended community entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
BGP using 1076 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 15 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 100 42 43 5 0 0 00:37:21 1
重分布
R2
#把OSPF重分布到BGP
R2(config)#router bgp 100
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)#redistribute ospf 1 vrf SITE1 match internal external 1 external 2
#把bgp重分布到ospf
R2(config)#router ospf 1 vrf SITE1
R2(config-router)#redistribute bgp 100 subnets
R4
#把OSPF重分布到BGP
R4(config)#router bgp 100
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#redistribute ospf 1 vrf SITE2 match internal external 1 external 2
#把bgp重分布到ospf
R4(config)#router ospf 1 vrf SITE2
R4(config-router)# redistribute bgp 100 subnets
vpn测试
R1
R1#ping 192.168.5.5 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.5.5, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 24/53/76 ms
R5
R5#ping 192.168.1.1 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 44/52/60 ms
标签情况
R2#show ip bgp vpnv4 all labels
Network Next Hop In label/Out label
Route Distinguisher: 1:1 (SITE1)
12.1.1.0/24 0.0.0.0 19/aggregate(SITE1)
45.1.1.0/24 4.4.4.4 nolabel/20
192.168.1.1/32 12.1.1.1 20/nolabel
192.168.5.5/32 4.4.4.4 nolabel/19
Route Distinguisher: 2:2
45.1.1.0/24 4.4.4.4 nolabel/20
192.168.5.5/32 4.4.4.4 nolabel/19
R4#show ip bgp vpnv4 all labels
Network Next Hop In label/Out label
Route Distinguisher: 1:1
12.1.1.0/24 2.2.2.2 nolabel/19
192.168.1.1/32 2.2.2.2 nolabel/20
Route Distinguisher: 2:2 (SITE2)
12.1.1.0/24 2.2.2.2 nolabel/19
45.1.1.0/24 0.0.0.0 20/aggregate(SITE2)
192.168.1.1/32 2.2.2.2 nolabel/20
192.168.5.5/32 45.1.1.5 19/nolabel
R3#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 2.2.2.2/32 9381 Fa0/0 23.1.1.2
17 Pop tag 4.4.4.4/32 16803 Fa0/1 34.1.1.4
PE-CE间路由协议-BGP
配置VPNV4
R2
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no bgp default ipv4-unicast
R2(config-router)#neighbor 4.4.4.4 remote-as 100
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#address-family vpnv4
R2(config-router-af)#neighbor 4.4.4.4 activate
R4
R4(config)#router bgp 100
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#neighbor 2.2.2.2 remote-as 100
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate
配置PE-CE路由(bgp)
R2
R2(config)#router bgp 100
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)#neighbor 12.1.1.1 remote-as 200
R2(config-router-af)#neighbor 12.1.1.1 activate
R4
R4(config)#router bgp 100
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#neighbor 45.1.1.5 remote-as 200
R4(config-router-af)#neighbor 45.1.1.5 activate
R1
R1(config)#router bgp 200
R1(config-router)#no synchronization
R1(config-router)#network 192.168.1.0 mask 255.255.255.0
R1(config-router)#neighbor 12.1.1.2 remote-as 100
R1(config-router)#no auto-summary
R5
R5(config)#router bgp 200
R5(config-router)#no synchronization
R5(config-router)#network 192.168.5.0 mask 255.255.255.0
R5(config-router)#neighbor 45.1.1.4 remote-as 100
R5(config-router)#no auto-summary
查看邻居状态
R2
R2#show ip bgp vpnv4 all summary
BGP router identifier 2.2.2.2, local AS number 100
BGP table version is 29, main routing table version 29
3 network entries using 420 bytes of memory
3 path entries using 204 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
2 BGP extended community entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 2 (at peak 2) using 64 bytes of memory
BGP using 1256 total bytes of memory
BGP activity 13/10 prefixes, 13/10 paths, scan interval 15 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4 4 100 162 161 29 0 0 02:03:39 1
12.1.1.1 4 200 20 20 29 0 0 00:15:58 1
R4
R4#show ip bgp vpnv4 all summary
BGP router identifier 4.4.4.4, local AS number 100
BGP table version is 26, main routing table version 26
3 network entries using 420 bytes of memory
3 path entries using 204 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
2 BGP extended community entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 2 (at peak 2) using 64 bytes of memory
BGP using 1256 total bytes of memory
BGP activity 12/9 prefixes, 12/9 paths, scan interval 15 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 100 137 138 26 0 0 02:04:33 1
45.1.1.5 4 200 21 21 26 0 0 00:16:45 1
配置bgp是不需要配置重分布,但是在我们的设计的时候两边的as号是一样的都是200,默认是不接收与自己相同as号的路由条目,解决方式
1、As-override:把AS-PATH含有的和CE AS号相同的AS号,全部替换成自己的AS号。(在PE设备配置)
R2
R2(config)#router bgp 100
R2(config-router)# address-family ipv4 vrf SITE1
R2(config-router-af)# neighbor 12.1.1.1 as-override
R4
R4(config)#router bgp 100
R4(config-router)# address-family ipv4 vrf SITE2
R4(config-router-af)# neighbor 45.1.1.5 as-override
2、Allowas-in 表示允许接收BGP条目中含有几次自己的AS-PATH
(在CE设备配置)
R1
R1(config)#router bgp 200
R1(config-router)#neighbor 12.1.1.2 allowas-in 1
R5
R5(config)#router bgp 200
R5(config-router)#neighbor 45.1.1.4 allowas-in 1
vpn测试
R1
R1#ping 192.168.5.5 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.5.5, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/73/92 ms
R5
R5#ping 192.168.1.1 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/57/76 ms
标签情况
R2#show ip bgp vpnv4 all labels
Network Next Hop In label/Out label
Route Distinguisher: 1:1 (SITE1)
192.168.1.0 12.1.1.1 20/nolabel
192.168.5.0 4.4.4.4 nolabel/19
Route Distinguisher: 2:2
192.168.5.0 4.4.4.4 nolabel/19
R4#show ip bgp vpnv4 all labels
Network Next Hop In label/Out label
Route Distinguisher: 1:1
192.168.1.0 2.2.2.2 nolabel/20
Route Distinguisher: 2:2 (SITE2)
192.168.1.0 2.2.2.2 nolabel/20
192.168.5.0 45.1.1.5 19/nolabel
R3#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 2.2.2.2/32 16621 Fa0/0 23.1.1.2
17 Pop tag 4.4.4.4/32 27607 Fa0/1 34.1.1.4
PE-CE间路由协议-RIP
配置PE-CE路由(rip)
R2
R2(config)#router rip
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)#network 12.1.1.0
R2(config-router-af)#no auto-summary
R2(config-router-af)#version 2
R4
R4(config)#router rip
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#network 45.1.1.0
R4(config-router-af)#no auto-summary
R4(config-router-af)#version 2
R1
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 192.168.1.0
R1(config-router)#network 12.0.0.0
R1(config-router)#no auto-summary
R5
R5(config)#router rip
R5(config-router)#version 2
R5(config-router)#network 192.168.5.0
R5(config-router)#network 45.0.0.0
R5(config-router)#no auto-summary
配置VPNV4
R2
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no bgp default ipv4-unicast
R2(config-router)#neighbor 4.4.4.4 remote-as 100
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#address-family vpnv4
R2(config-router-af)#neighbor 4.4.4.4 activate
R4
R4(config)#router bgp 100
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#neighbor 2.2.2.2 remote-as 100
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate
查看邻居状态
R2
R2#show ip bgp vpnv4 all summary
BGP router identifier 2.2.2.2, local AS number 100
BGP table version is 16, main routing table version 16
6 network entries using 840 bytes of memory
6 path entries using 408 bytes of memory
5/4 BGP path/bestpath attribute entries using 620 bytes of memory
2 BGP extended community entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 1948 total bytes of memory
BGP activity 9/3 prefixes, 9/3 paths, scan interval 15 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4 4 100 28 28 16 0 0 00:18:13 2
R4
R4#show ip bgp vpnv4 all summary
BGP router identifier 4.4.4.4, local AS number 100
BGP table version is 16, main routing table version 16
6 network entries using 840 bytes of memory
6 path entries using 408 bytes of memory
5/4 BGP path/bestpath attribute entries using 620 bytes of memory
2 BGP extended community entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
Bitfield cache entries: current 1 (at peak 2) using 32 bytes of memory
BGP using 1948 total bytes of memory
BGP activity 9/3 prefixes, 9/3 paths, scan interval 15 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 100 28 28 16 0 0 00:18:18 2
重分布
R2
#将rip重分布到bgp
R2(config)#router bgp 100
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)#redistribute rip
#将BGP重分步到RIP
R2(config)#router rip
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)#redistribute bgp 100 metric 1
R4
#将rip重分布到bgp
R4(config)#router bgp 100
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#redistribute rip
#将BGP重分步到RIP
R4(config)#router rip
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#redistribute bgp 100 metric 1
查看重分布之后的路由情况
R2
R2#show ip bgp vpnv4 vrf SITE1
BGP table version is 16, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf SITE1)
*> 12.1.1.0/24 0.0.0.0 0 32768 ?
*>i45.1.1.0/24 4.4.4.4 0 100 0 ?
*> 192.168.1.0 12.1.1.1 1 32768 ?
*>i192.168.5.0 4.4.4.4 1 100 0 ?
R4
R4#show ip bgp vpnv4 vrf SITE2
BGP table version is 16, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 2:2 (default for vrf SITE2)
*>i12.1.1.0/24 2.2.2.2 0 100 0 ?
*> 45.1.1.0/24 0.0.0.0 0 32768 ?
*>i192.168.1.0 2.2.2.2 1 100 0 ?
*> 192.168.5.0 45.1.1.5 1 32768 ?
vpn测试
R1
R1#ping 192.168.5.5 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.5.5, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
.!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 20/46/72 ms
R5
R5#ping 192.168.1.1 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/64/72 ms
标签情况
R2#show ip bgp vpnv4 all labels
Network Next Hop In label/Out label
Route Distinguisher: 1:1 (SITE1)
12.1.1.0/24 0.0.0.0 19/aggregate(SITE1)
45.1.1.0/24 4.4.4.4 nolabel/20
192.168.1.0 12.1.1.1 20/nolabel
192.168.5.0 4.4.4.4 nolabel/19
Route Distinguisher: 2:2
45.1.1.0/24 4.4.4.4 nolabel/20
192.168.5.0 4.4.4.4 nolabel/19
R4#show ip bgp vpnv4 all labels
Network Next Hop In label/Out label
Route Distinguisher: 1:1
12.1.1.0/24 2.2.2.2 nolabel/19
192.168.1.0 2.2.2.2 nolabel/20
Route Distinguisher: 2:2 (SITE2)
12.1.1.0/24 2.2.2.2 nolabel/19
45.1.1.0/24 0.0.0.0 20/aggregate(SITE2)
192.168.1.0 2.2.2.2 nolabel/20
192.168.5.0 45.1.1.5 19/nolabel
R3#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 2.2.2.2/32 5562 Fa0/0 23.1.1.2
17 Pop tag 4.4.4.4/32 4384 Fa0/1 34.1.1.4
PE-CE间路由协议-EIGRP
配置PE-CE路由(eigrp)
R2
R2(config)#router eigrp 100
R2(config-router)#no auto-summary
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)#network 12.1.1.0 0.0.0.255
R2(config-router-af)#no auto-summary
R2(config-router-af)#autonomous-system 12
R4
R4(config)#router eigrp 100
R4(config-router)#no auto-summary
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#network 45.1.1.0 0.0.0.255
R4(config-router-af)#no auto-summary
R4(config-router-af)#autonomous-system 45
R1
R1(config)#no router eigrp 100
R1(config)#router eigrp 12
R1(config-router)# network 192.168.1.0
R1(config-router)# network 12.1.1.0 0.0.0.255
R1(config-router)# no auto-summary
R5
R5(config)#router eigrp 45
R5(config-router)# network 192.168.5.0
R5(config-router)# network 45.1.1.0 0.0.0.255
R5(config-router)# no auto-summary
配置VPNV4
R2
R2(config)#router bgp 100
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no bgp default ipv4-unicast
R2(config-router)#neighbor 4.4.4.4 remote-as 100
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#address-family vpnv4
R2(config-router-af)#neighbor 4.4.4.4 activate
R4
R4(config)#router bgp 100
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#no bgp default ipv4-unicast
R4(config-router)#neighbor 2.2.2.2 remote-as 100
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#address-family vpnv4
R4(config-router-af)#neighbor 2.2.2.2 activate
查看邻居状态
R2
R2#sh ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 23.1.1.3 Fa0/1 13 00:35:51 23 675 0 19
####R4
R4#sh ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 34.1.1.3 Fa0/1 12 00:36:43 20 200 0 17
重分布
R2
#把eigrp重分布到bgp
R2(config)#router bgp 100
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)# redistribute eigrp 12
#把bgp重分布到eigrp
R2(config-router-af)#router eigrp 100
R2(config-router)#address-family ipv4 vrf SITE1
R2(config-router-af)# redistribute bgp 100 metric 10000 100 255 1 1500
R4
#把eigrp重分布到bgp
R4(config)#router bgp 100
R4(config-router)#address-family ipv4 vrf SITE2
R4(config-router-af)#redistribute eigrp 45
#把bgp重分布到eigrp
R4(config-router-af)#router eigrp 100
R4(config-router)# address-family ipv4 vrf SITE2
R4(config-router-af)# redistribute bgp 100 metric 10000 100 255 1 1500
查看重分布之后的路由情况
R2
R2#show ip route vrf SITE1
Routing Table: SITE1
Codes: 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
Gateway of last resort is not set
B 192.168.5.0/24 [200/409600] via 4.4.4.4, 00:03:02
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
D 192.168.1.0/24 [90/409600] via 12.1.1.1, 00:13:21, FastEthernet0/0
45.0.0.0/24 is subnetted, 1 subnets
B 45.1.1.0 [200/0] via 4.4.4.4, 00:03:02
R4
R4#show ip route vrf SITE2
*Mar 1 00:44:18.223: %SYS-5-CONFIG_I: Configured from console by console
Routing Table: SITE2
Codes: 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
Gateway of last resort is not set
D 192.168.5.0/24 [90/409600] via 45.1.1.5, 00:13:37, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
B 12.1.1.0 [200/0] via 2.2.2.2, 00:05:53
B 192.168.1.0/24 [200/409600] via 2.2.2.2, 00:05:53
45.0.0.0/24 is subnetted, 1 subnets
C 45.1.1.0 is directly connected, FastEthernet0/0
vpn测试
R1
R1#ping 192.168.5.5 source 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.5.5, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 136/148/172 ms
R5
R5#ping 192.168.1.1 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/52/72 ms
标签情况
R1#traceroute 192.168.5.5 source 192.168.1.1
Type escape sequence to abort.
Tracing the route to 192.168.5.5
1 12.1.1.2 56 msec 60 msec 84 msec
2 23.1.1.3 [MPLS: Labels 17/19 Exp 0] 144 msec 176 msec 168 msec
3 45.1.1.4 [MPLS: Label 19 Exp 0] 152 msec 100 msec 100 msec
4 45.1.1.5 152 msec 112 msec *