如下方拓扑所示,共分为4个AS。PE1、P1和ASBR1属于AS100,PE2、P2和ASBR2属于AS200。CE1和CE2属于同一个VPN,CE1通过AS100的PE1接入,CE2通过AS200 的PE2接入,其分别属于AS65001与AS65002。
sysname CE1 #配置主机名
interface GigabitEthernet0/0/1
ip address 10.1.1.1 255.255.255.252
#
interface LoopBack0
ip address 11.11.11.11 255.255.255.255
#
interface GigabitEthernet0/0/0
ip address 12.12.12.1 255.255.255.252
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
interface GigabitEthernet0/0/0
ip address 12.12.12.2 255.255.255.252
#
interface GigabitEthernet0/0/1
ip address 23.23.23.1 255.255.255.252
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
interface GigabitEthernet0/0/1
ip address 23.23.23.2 255.255.255.252
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
interface GigabitEthernet0/0/1
ip address 45.45.45.1 255.255.255.252
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
interface GigabitEthernet0/0/0
ip address 56.56.56.1 255.255.255.252
interface GigabitEthernet0/0/1
ip address 45.45.45.2 255.255.255.252
#
interface LoopBack0
ip address 5.5.5.5 255.255.255.255
interface GigabitEthernet0/0/0
ip address 56.56.56.2 255.255.255.252
#
interface LoopBack0
ip address 6.6.6.6 255.255.255.255
interface GigabitEthernet0/0/1
ip address 20.1.1.2 255.255.255.252
#
interface LoopBack0
ip address 22.22.22.22 255.255.255.255
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 12.12.12.0 0.0.0.3
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 12.12.12.0 0.0.0.3
network 23.23.23.0 0.0.0.3
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 23.23.23.0 0.0.0.3
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 45.45.45.0 0.0.0.3
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 5.5.5.5 0.0.0.0
network 45.45.45.0 0.0.0.3
network 56.56.56.0 0.0.0.3
ospf 1 router-id 6.6.6.6
area 0.0.0.0
network 6.6.6.6 0.0.0.0
network 56.56.56.0 0.0.0.3
mpls lsr-id 1.1.1.1
mpls
#
mpls ldp
interface GigabitEthernet0/0/0
mpls
mpls ldp
mpls lsr-id 2.2.2.2
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 12.12.12.2 255.255.255.252
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 23.23.23.1 255.255.255.252
mpls
mpls ldp
mpls lsr-id 3.3.3.3
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 23.23.23.2 255.255.255.252
mpls
mpls ldp
#
mpls lsr-id 4.4.4.4
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip binding -instance huawei
ip address 34.34.34.2 255.255.255.252
#
interface GigabitEthernet0/0/1
ip address 45.45.45.1 255.255.255.252
mpls
mpls ldp
mpls lsr-id 5.5.5.5
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 56.56.56.1 255.255.255.252
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 45.45.45.2 255.255.255.252
mpls
mpls ldp
mpls lsr-id 6.6.6.6
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 56.56.56.2 255.255.255.252
mpls
mpls ldp
bgp 100
peer 3.3.3.3 as-number 100 #配置PE1与ASBR1之间的IBGP邻居关系
peer 3.3.3.3 connect-interface LoopBack0 #配置建立对等体的接口为looback 0;
#
ipv4-family unicast
undo synchronization
peer 3.3.3.3 enable
#
ipv4-family v4 #进入BGP的VPNv4视图
policy -target
peer 3.3.3.3 enable #使能PE1与ASBR1的MP-IBGP邻居
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 1.1.1.1 enable
#
ipv4-family v4
policy -target
peer 1.1.1.1 enable
bgp 200
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 4.4.4.4 enable
#
ipv4-family v4
policy -target
peer 4.4.4.4 enable
bgp 200
peer 6.6.6.6 as-number 200
peer 6.6.6.6 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 6.6.6.6 enable
#
ipv4-family v4
policy -target
peer 6.6.6.6 enable
ip -instance huawei #创建VPN实例
ipv4-family
route-distinguisher 100:1 #配置RD属性
-target 100:1 export-extcommunity #配置RT属性
-target 100:1 import-extcommunity
interface GigabitEthernet0/0/1 #接口绑定VPN实例,注意绑定VPN实例后,接口的所有配置都将被清空
ip binding -instance huawei
ip address 10.1.1.2 255.255.255.252
&nsbp;
ip -instance huawei
ipv4-family
route-distinguisher 100:1
-target 100:1 export-extcommunity
-target 100:1 import-extcommunity
interface GigabitEthernet0/0/0
ip binding -instance huawei
ip address 34.34.34.1 255.255.255.252
&nsbp;
#
ip -instance huawei
ipv4-family
route-distinguisher 100:1
-target 100:1 export-extcommunity
-target 100:1 import-extcommunity
interface GigabitEthernet0/0/0
ip binding -instance huawei
ip address 34.34.34.2 255.255.255.252
&nsbp;
ip -instance huawei
ipv4-family
route-distinguisher 100:1
-target 100:1 export-extcommunity
-target 100:1 import-extcommunity
interface GigabitEthernet0/0/1
ip binding -instance huawei
ip address 20.1.1.1 255.255.255.252
bgp 100
#
ipv4-family -instance huawei
peer 10.1.1.1 as-number 65001 #配置PE1与CE1的BGP邻居关系
#
bgp 65001
peer 10.1.1.2 as-number 100
#
ipv4-family unicast
undo synchronization
network 11.11.11.11 255.255.255.255
peer 10.1.1.2 enable
bgp 100 #配置ASBR1与ASBR2的BGP邻居关系
ipv4-family -instance huawei
peer 34.34.34.2 as-number 200
bgp 200
ipv4-family -instance huawei
peer 34.34.34.1 as-number 100
bgp 200
ipv4-family -instance huawei
peer 20.1.1.2 as-number 65002
bgp 65002
peer 20.1.1.1 as-number 200
#
ipv4-family unicast
undo synchronization
network 22.22.22.22 255.255.255.255
peer 20.1.1.1 enable