需求:上面两台交换机模拟企业1的两个分支,下面两台交换机模拟企业2的两个分支。要求企业1的分支间通过VPN1互访,企业2的分支间通过VPN2互访,不同企业分支间不得访问。
图例:灰色的点代表下层协议,黄色的点代表上层协议。一头灰色一头黄色代表运行在不同层的相同协议。比如OSPF一端是普通OSPF,另一端是基于VPN实例的。
总体配置过程
1.物理口与环回口地址配置
2.公网三台路由器建立OSPF 1邻居
3.公网三台路由器建立MPLS LDP邻居
4.PE设备边缘端口绑定对应的VPN实例
5.PE与CE间建立OSPF邻居
6.PE与PE间建立BGP 100邻居,使能IPV4、VPNV4
7.PE上OSPF与BGP双向重分发,BGP还需重分发直连路由
配置示例
#
sysname R1
#
ip vpn-instance vpn1
route-distinguisher 100:1
vpn-target 100:1 import-extcommunity
vpn-target 100:1 export-extcommunity
#
ip vpn-instance vpn2
route-distinguisher 200:1
vpn-target 200:1 import-extcommunity
vpn-target 200:1 export-extcommunity
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 12.1.1.1 0.0.0.0
#
ospf 10 vpn-instance vpn1
import-route bgp
area 0.0.0.0
network 172.16.14.1 0.0.0.0
#
ospf 20 vpn-instance vpn2
import-route bgp
area 0.0.0.0
network 172.16.15.1 0.0.0.0
#
mpls lsr-id 1.1.1.1
#
mpls ldp
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
interface GigabitEthernet0/0
port link-mode route
combo enable copper
ip address 12.1.1.1 255.255.255.0
mpls enable
mpls ldp enable
#
interface GigabitEthernet0/1
port link-mode route
combo enable copper
ip binding vpn-instance vpn1
ip address 172.16.14.1 255.255.255.0
#
interface GigabitEthernet0/2
port link-mode route
combo enable copper
ip binding vpn-instance vpn2
ip address 172.16.15.1 255.255.255.0
#
bgp 100
peer 3.3.3.3 as-number 100
peer 3.3.3.3 connect-interface LoopBack0
#
address-family ipv4 unicast
peer 3.3.3.3 enable
#
address-family vpnv4
peer 3.3.3.3 enable
#
ip vpn-instance vpn1
#
address-family ipv4 unicast
import-route direct
import-route ospf 10
#
ip vpn-instance vpn2
#
address-family ipv4 unicast
import-route ospf 20
#
#
sysname R2
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 12.1.1.2 0.0.0.0
network 23.1.1.2 0.0.0.0
#
mpls lsr-id 2.2.2.2
#
mpls ldp
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
interface GigabitEthernet0/0
port link-mode route
combo enable copper
ip address 12.1.1.2 255.255.255.0
mpls enable
mpls ldp enable
#
interface GigabitEthernet0/1
port link-mode route
combo enable copper
ip address 23.1.1.2 255.255.255.0
mpls enable
mpls ldp enable
#
#
sysname R3
#
ip vpn-instance vpn1
route-distinguisher 100:1
vpn-target 100:1 import-extcommunity
vpn-target 100:1 export-extcommunity
#
ip vpn-instance vpn2
route-distinguisher 200:1
vpn-target 200:1 import-extcommunity
vpn-target 200:1 export-extcommunity
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 23.1.1.3 0.0.0.0
#
ospf 10 vpn-instance vpn1
import-route bgp
area 0.0.0.0
network 172.16.36.3 0.0.0.0
#
ospf 20 vpn-instance vpn2
import-route bgp
area 0.0.0.0
network 172.16.37.3 0.0.0.0
#
mpls lsr-id 3.3.3.3
#
mpls ldp
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
interface GigabitEthernet0/0
port link-mode route
combo enable copper
ip address 23.1.1.3 255.255.255.0
mpls enable
mpls ldp enable
#
interface GigabitEthernet0/1
port link-mode route
combo enable copper
ip binding vpn-instance vpn1
ip address 172.16.36.3 255.255.255.0
#
interface GigabitEthernet0/2
port link-mode route
combo enable copper
ip binding vpn-instance vpn2
ip address 172.16.37.3 255.255.255.0
#
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
#
address-family ipv4 unicast
peer 1.1.1.1 enable
#
address-family vpnv4
peer 1.1.1.1 enable
#
ip vpn-instance vpn1
#
address-family ipv4 unicast
import-route direct
import-route ospf 10
#
ip vpn-instance vpn2
#
address-family ipv4 unicast
import-route direct
import-route ospf 20
#
#
sysname SW4
#
ospf 10
area 0.0.0.0
network 172.16.14.4 0.0.0.0
network 192.168.4.1 0.0.0.0
#
interface LoopBack0
ip address 192.168.4.1 255.255.255.255
#
interface GigabitEthernet1/0/1
port link-mode route
combo enable fiber
ip address 172.16.14.4 255.255.255.0
#
#
sysname SW5
#
ospf 20
area 0.0.0.0
network 172.16.15.5 0.0.0.0
network 192.168.5.1 0.0.0.0
#
interface LoopBack0
ip address 192.168.5.1 255.255.255.255
#
interface GigabitEthernet1/0/1
port link-mode route
combo enable fiber
ip address 172.16.15.5 255.255.255.0
#
#
sysname SW6
#
ospf 10
area 0.0.0.0
network 172.16.36.6 0.0.0.0
network 192.168.6.1 0.0.0.0
#
interface LoopBack0
ip address 192.168.6.1 255.255.255.255
#
interface GigabitEthernet1/0/1
port link-mode route
combo enable fiber
ip address 172.16.36.6 255.255.255.0
#
#
sysname SW7
#
ospf 20
area 0.0.0.0
network 172.16.37.7 0.0.0.0
network 192.168.7.1 0.0.0.0
#
interface LoopBack0
ip address 192.168.7.1 255.255.255.255
#
interface GigabitEthernet1/0/1
port link-mode route
combo enable fiber
ip address 172.16.37.7 255.255.255.0
#