配置mpls vpn
拓扑如下:
配置思路:
1.公网互通
2.建立vpn实例
3.在两台PE间建立MP-BGP VPN
4.ospf与bgp的双向引入
配置ip,启用ospf全网互通
**R1**
#
interface GigabitEthernet0/0/0
ip address 192.168.1.1 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
interface LoopBack10
ip address 172.16.1.1 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 172.16.1.1 0.0.0.0
network 192.168.1.1 0.0.0.0
#
------------------------------------------------
**R2**
#
interface GigabitEthernet0/0/0
ip address 192.168.1.2 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
interface LoopBack10
ip address 172.16.2.1 255.255.255.255
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 172.16.2.1 0.0.0.0
network 192.168.1.2 0.0.0.0
#
------------------------------------------------
R6与R7的配置略
------------------------------------------------
**R3**
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
interface GigabitEthernet0/0/2
ip address 100.1.34.1 255.255.255.252
#
先不配置g0/0/0口和g0/0/1
#
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.34.1 0.0.0.0
#
------------------------------------------------
**R4**
#
interface GigabitEthernet0/0/0
ip address 100.1.34.2 255.255.255.252
#
interface GigabitEthernet0/0/1
ip address 100.1.45.1 255.255.255.252
#
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 100.1.34.2 0.0.0.0
network 100.1.45.1 0.0.0.0
#
------------------------------------------------
**R5**
#
interface GigabitEthernet0/0/0
ip address 100.1.45.2 255.255.255.252
#
在公网区域内开启mpls ldp
**R3**
#
mpls lsr-id 3.3.3.3
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/2
mpls
mpls ldp
#
------------------------------------------------
**R4**
#
mpls lsr-id 4.4.4.4
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
mpls
mpls ldp
#
------------------------------------------------
**R5**
#
mpls lsr-id 5.5.5.5
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
mpls
mpls ldp
#
在PE设备中开启vpn实例,并绑定到相应接口
**R3**
#
ip vpn-instance 1
ipv4-family
route-distinguisher 1:2
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
#
interface GigabitEthernet0/0/0
ip binding vpn-instance 1
ip address 192.168.1.3 255.255.255.0
#
interface GigabitEthernet0/0/1
ip binding vpn-instance 2
ip address 192.168.1.3 255.255.255.0
#
------------------------------------------------
**R5**
#
ip vpn-instance 1
ipv4-family
route-distinguisher 1:2
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
#
interface GigabitEthernet0/0/1
ip binding vpn-instance 1
ip address 192.168.2.3 255.255.255.0
#
interface GigabitEthernet0/0/2
ip binding vpn-instance 2
ip address 192.168.2.3 255.255.255.0
#
CE设备和PE设备配置私网路由
**R3**
#
ospf 100 vpn-instance 1
area 0.0.0.0
network 192.168.1.3 0.0.0.0
#
ospf 200 vpn-instance 2
area 0.0.0.0
network 192.168.1.3 0.0.0.0
#
------------------------------------------------
**R5**
#
ospf 100 vpn-instance 1
area 0.0.0.0
network 192.168.2.3 0.0.0.0
#
ospf 200 vpn-instance 2
area 0.0.0.0
network 192.168.2.3 0.0.0.0
#
配置MP-BGP VPN
**R3**
#
bgp 300
peer 5.5.5.5 as-number 300
peer 5.5.5.5 connect-interface LoopBack0
#
ipv4-family vpnv4
policy vpn-target
peer 5.5.5.5 enable
--------------------------------------------
**R5**
#
bgp 300
peer 3.3.3.3 as-number 300
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family vpnv4
policy vpn-target
peer 3.3.3.3 enable
配置ospf和bgp的双向引入
**R3**
#
ospf 100 vpn-instance 1
import-route bgp
#
ospf 200 vpn-instance 2
import-route bgp
#
#
bgp 300
#
ipv4-family vpn-instance 1
import-route ospf 100
#
ipv4-family vpn-instance 2
import-route ospf 200
#
-----------------------------------------
**R5**
#
ospf 100 vpn-instance 1
import-route bgp
#
ospf 200 vpn-instance 2
import-route bgp
#
#
bgp 300
#
ipv4-family vpn-instance 1
import-route ospf 100
#
ipv4-family vpn-instance 2
import-route ospf 200
#
通道建立成功