配置BGP AS号替换示例
同一VPN不同站点的AS号相同,并且PE与CE之间建立EBGP连接时,需要在PE设备上使能AS号替换功能,否则本地CE会丢弃携带有与本地AS相同的VPN路由,造成VPN用户之间不能互通。
组网需求
如图7-22,CE1和CE2属于同一个VPN,分别接入PE1和PE2,并且CE1和CE2复用AS号600。当PE与CE之间运行EBGP协议时,从CE上发往PE的BGP路由,携带有AS_Path属性。本地PE通过MP-IBGP协议传给对端PE,当对端PE通过EBGP将这些路由发给其CE时,会因为AS_Path中已携带有AS号600而丢弃这些路由。
现要求在PE上配置AS号替换功能,对于PE通过BGP发给CE的VPN路由,PE会把其AS号替换成自己的,也就是AS 100,从而使CE能够接收到远端的VPN路由。
操作步骤
- 配置基本BGP/MPLS IP VPN
包括以下配置:
在MPLS骨干网上配置OSPF,PE和P之间能够学到对方Loopback接口的路由;
在MPLS骨干网上配置MPLS基本能力和MPLS LDP,建立LDP LSP;
PE之间建立MP-IBGP对等体关系,发布VPNv4路由;
在PE1上配置使能IPv4地址族的VPN实例,并将CE1接入PE1;
在PE2上配置使能IPv4地址族的VPN实例,并将CE2接入PE2;
PE1和CE1、PE2和CE2之间配置EBGP,将CE的路由引入PE。
具体配置请参见配置文件。
完成上述配置后,在CE2上执行display ip routing-table命令,可以看到CE2能够学到CE1接入PE1的接口所在网段(10.1.1.0/24)的路由,但没有到达CE1内部VPN(172.16.1.0/24)的路由。CE1上也存在同样的现象。
<CE2> display ip routing-table
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Tables: _public_
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 EBGP 255 0 D 10.2.1.2 GigabitEthernet1/0/0
10.1.1.1/32 EBGP 255 0 D 10.2.1.2 GigabitEthernet1/0/0
10.2.1.0/24 Direct 0 0 D 10.2.1.1 GigabitEthernet1/0/0
10.2.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
10.2.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.16.2.0/24 Direct 0 0 D 172.16.2.1 GigabitEthernet2/0/0
172.16.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet2/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
在PE上执行display ip routing-table vpn-instance命令,可以看到PE的VPN实例IPv4地址族中有到达对端CE内部VPN的路由。
以PE2的显示为例:
<PE2> display ip routing-table vpn-instance vpn1
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Tables: vpn1
Destinations : 9 Routes : 9
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 IBGP 255 0 RD 1.1.1.9 GigabitEthernet2/0/0
10.1.1.1/32 IBGP 255 0 RD 1.1.1.9 GigabitEthernet2/0/0
10.1.1.2/32 IBGP 255 0 RD 1.1.1.9 GigabitEthernet2/0/0
10.2.1.0/24 Direct 0 0 D 10.2.1.2 GigabitEthernet1/0/0
10.2.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
10.2.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
172.16.1.0/24 IBGP 255 0 RD 1.1.1.9 GigabitEthernet2/0/0
172.16.2.0/24 EBGP 255 0 D 10.2.1.1 GigabitEthernet1/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
在CE2上执行display bgp routing-table peer received-routes命令,可以看到CE2没有接收到到达172.16.1.0/24的路由。
<CE2> display bgp routing-table peer 10.2.1.2 received-routes
BGP Local router ID is 10.2.1.1
Status codes: * - valid, > - best, d - damped, x - best external, a - add path,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V - valid, I - invalid, N - not-found
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.1.0/24 10.2.1.2 0 100?
*> 10.1.1.1/32 10.2.1.2 0 100?
* 10.2.1.0/24 10.2.1.2 0 0 100?
*> 10.2.1.1/32 10.2.1.2 0 0 100?
- 配置BGP的AS号替换功能
在PE上配置BGP的AS号替换功能。
# 以PE2上的配置为例。
[~PE2] bgp 100
[*PE2-bgp] ipv4-family vpn-instance vpn1
[*PE2-bgp-vpn1] peer 10.2.1.1 substitute-as
[*PE2-bgp-vpn1] commit
再次查看CE2接收的路由信息和路由表:
<CE2> display bgp routing-table peer 10.2.1.2 received-routes
BGP Local router ID is 10.2.1.1
Status codes: * - valid, > - best, d - damped, x - best external, a - add path,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V - valid, I - invalid, N - not-found
Total Number of Routes: 6
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.1.0/24 10.2.1.2 0 100?
*> 10.1.1.1/32 10.2.1.2 0 100?
*> 10.1.1.2/32 10.2.1.2 0 100 100?
* 10.2.1.0/24 10.2.1.2 0 0 100?
* 10.2.1.1/32 10.2.1.2 0 0 100?
*> 172.16.1.0/24 10.2.1.2 0 100 100?
<CE2> display ip routing-table
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Tables: _public_
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 EBGP 255 0 D 10.2.1.2 GigabitEthernet1/0/0
10.1.1.1/32 EBGP 255 0 D 10.2.1.2 GigabitEthernet1/0/0
10.2.1.0/24 Direct 0 0 D 10.2.1.1 GigabitEthernet1/0/0
10.2.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
10.2.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet1/0/0
172.16.1.1/24 EBGP 255 0 D 10.2.1.2 GigabitEthernet1/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.16.2.0/24 Direct 0 0 D 127.0.0.1 GigabitEthernet2/0/0
172.16.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet2/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
在PE1上也配置BGP的AS号替换功能后,CE1和CE2的GigabitEthernet接口能够相互Ping通。
[*CE1] ping –a 172.16.1.1 172.16.2.1
PING 172.16.2.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.1: bytes=56 Sequence=1 ttl=253 time=109 ms
Reply from 172.16.2.1: bytes=56 Sequence=2 ttl=253 time=67 ms
Reply from 172.16.2.1: bytes=56 Sequence=3 ttl=253 time=66 ms
Reply from 172.16.2.1: bytes=56 Sequence=4 ttl=253 time=85 ms
Reply from 172.16.2.1: bytes=56 Sequence=5 ttl=253 time=70 ms
--- 172.16.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 66/79/109 ms
配置文件
CE1的配置文件
#
sysname CE1
#
interface GigabitEthernet1/0/0
undo shutdown
ip address 10.1.1.1 255.255.255.0
#
interface GigabitEthernet2/0/0
undo shutdown
ip address 172.16.1.1 255.255.255.0
#
bgp 600
peer 10.1.1.2 as-number 100
#
ipv4-family unicast
undo synchronization import-route direct
peer 10.1.1.2 enable
#
return
PE1的配置文件
#
sysname PE1
#
ip vpn-instance vpn1
ipv4-family
route-distinguisher 100:1
apply-label per-instance
vpn-target 1:1 export-extcommunity
vpn-target 1:1 import-extcommunity
#
mpls lsr-id 1.1.1.9
#
mpls
#
mpls ldp
#
interface GigabitEthernet1/0/0
undo shutdown
ip binding vpn-instance vpn1
ip address 10.1.1.2 255.255.255.0
#
interface GigabitEthernet2/0/0
undo shutdown
ip address 20.1.1.1 255.255.255.0
mpls
mpls ldp
#
interface LoopBack1
ip address 1.1.1.9 255.255.255.255
#
bgp 100
peer 3.3.3.9 as-number 100
peer 3.3.3.9 connect-interface LoopBack1
#
ipv4-family unicast
undo synchronization peer 3.3.3.9 enable
#
ipv4-family vpnv4
policy vpn-target
peer 3.3.3.9 enable
#
ipv4-family vpn-instance vpn1
peer 10.1.1.1 as-number 600
peer 10.1.1.1 substitute-as
import-route direct
#
ospf 1
area 0.0.0.0
network 1.1.1.9 0.0.0.0
network 20.1.1.0 0.0.0.255
#
return
P的配置文件
#
sysname P
#
mpls lsr-id 2.2.2.9
#
mpls
#
mpls ldp
#
interface GigabitEthernet1/0/0
undo shutdown
ip address 20.1.1.2 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet2/0/0
undo shutdown
ip address 30.1.1.1 255.255.255.0
mpls
mpls ldp
#
interface LoopBack1
ip address 2.2.2.9 255.255.255.255
#
ospf 1
area 0.0.0.0
network 2.2.2.9 0.0.0.0
network 20.1.1.0 0.0.0.255
network 30.1.1.0 0.0.0.255
#
return
PE2的配置文件
#
sysname PE2
#
ip vpn-instance vpn1
ipv4-family
route-distinguisher 100:1
apply-label per-instance
vpn-target 1:1 export-extcommunity
vpn-target 1:1 import-extcommunity
#
mpls lsr-id 3.3.3.9
#
mpls
#
mpls ldp
#
interface GigabitEthernet1/0/0
undo shutdown
ip binding vpn-instance vpn1
ip address 10.2.1.2 255.255.255.0
#
interface GigabitEthernet2/0/0
undo shutdown
ip address 30.1.1.2 255.255.255.0
mpls
mpls ldp
#
interface LoopBack1
ip address 3.3.3.9 255.255.255.255
#
bgp 100
peer 1.1.1.9 as-number 100
peer 1.1.1.9 connect-interface LoopBack1
#
ipv4-family unicast
undo synchronization peer 1.1.1.9 enable
#
ipv4-family vpnv4
policy vpn-target
peer 1.1.1.9 enable
#
ipv4-family vpn-instance vpn1
peer 10.2.1.1 as-number 600
peer 10.2.1.1 substitute-as
import-route direct
#
ospf 1
area 0.0.0.0
network 3.3.3.9 0.0.0.0
network 30.1.1.0 0.0.0.255
#
return
CE2的配置文件
#
sysname CE2
#
interface GigabitEthernet1/0/0
undo shutdown
ip address 10.2.1.1 255.255.255.0
#
interface GigabitEthernet2/0/0
undo shutdown
ip address 172.16.2.1 255.255.255.0
#
bgp 600
peer 10.2.1.2 as-number 100
#
ipv4-family unicast
undo synchronization import-route direct
peer 10.2.1.2 enable
#
return