公网网络互通
PE1:
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 100.1.1.1 0.0.0.0
P:
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 100.1.1.2 0.0.0.0
network 100.1.2.2 0.0.0.0
PE2:
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 100.1.2.1 0.0.0.0
PE与CE之间IP配置,创建VPN
PE1:
ip vpn-instance 1
ipv4-family
#
ip vpn-instance 2
ipv4-family
interface GigabitEthernet0/0/0
ip binding vpn-instance 1
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip binding vpn-instance 2
ip address 192.168.1.1 255.255.255.0
PE2:
ip vpn-instance 1
ipv4-family
#
ip vpn-instance 2
ipv4-family
interface GigabitEthernet0/0/0
ip binding vpn-instance 1
ip address 192.168.2.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip binding vpn-instance 2
ip address 192.168.2.1 255.255.255.0
PE、CE设备使用VPN配置私网路由
PE1:
ospf 100 router-id 1.1.1.1 vpn-instance 1
area 0.0.0.0
network 192.168.1.1 0.0.0.0
#
ospf 200 router-id 1.1.1.1 vpn-instance 2
area 0.0.0.0
network 192.168.1.1 0.0.0.0
CE1:
ospf 100 router-id 172.16.1.1
area 0.0.0.0
network 192.168.1.10 0.0.0.0
CE2:
ospf 100 router-id 172.16.2.1
area 0.0.0.0
network 192.168.1.20 0.0.0.0
PE2:
ospf 100 router-id 3.3.3.3 vpn-instance 1
area 0.0.0.0
network 192.168.2.1 0.0.0.0
#
ospf 200 router-id 3.3.3.3 vpn-instance 2
area 0.0.0.0
network 192.168.2.1 0.0.0.0
CE3:
ospf 100 router-id 172.16.3.1
area 0.0.0.0
network 192.168.2.10 0.0.0.0
CE4:
ospf 100 router-id 172.16.4.1
area 0.0.0.0
network 192.168.2.20 0.0.0.0
配置私网target
PE1:
ip vpn-instance 1
ipv4-family
route-distinguisher 1:1
vpn-target 100:200 export-extcommunity
vpn-target 100:100 import-extcommunity
#
ip vpn-instance 2
ipv4-family
route-distinguisher 2:2
vpn-target 200:200 export-extcommunity
vpn-target 200:100 import-extcommunity
PE2:
ip vpn-instance 1
ipv4-family
route-distinguisher 1:1
vpn-target 100:100 export-extcommunity
vpn-target 100:200 import-extcommunity
#
ip vpn-instance 2
ipv4-family
route-distinguisher 2:2
vpn-target 200:100 export-extcommunity
vpn-target 200:200 import-extcommunity
公网分配标签
PE1:
mpls lsr-id 1.1.1.1
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/2
mpls
mpls ldp
P:
mpls lsr-id 2.2.2.2
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/1
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
mpls
mpls ldp
PE2:
mpls lsr-id 3.3.3.3
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/1
mpls
mpls ldp
配置MP-BGP,实现公网设备传递私网路由
PE1:
bgp 100
peer 3.3.3.3 as-number 100
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
undo peer 3.3.3.3 enable
#
ipv4-family vpnv4
policy vpn-target
peer 3.3.3.3 enable
PE2:
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
undo peer 1.1.1.1 enable
#
ipv4-family vpnv4
policy vpn-target
peer 1.1.1.1 enable
双向引入
PE1:
bgp 100
#
ipv4-family vpn-instance 1
import-route ospf 100
#
ipv4-family vpn-instance 2
import-route ospf 200
ospf 100
import-route bgp
ospf 200
import-route bgp
PE2:
bgp 100
#
ipv4-family vpn-instance 1
import-route ospf 100
#
ipv4-family vpn-instance 2
import-route ospf 200
ospf 100
import-route bgp
ospf 200
import-route bgp
验证: