目录
5、R6-R7之间的私有IP地址通信优先使用MPLS(sham-link)
一、实验拓扑
二、实验要求
1.如图连接拓扑,合理规划IP地址,R1、R5、R6、R7各种创建一个环回,IP地址分别为192.168.1.0 、192.168.2.0、192.168.3.0、192.168.4.0
2.AS 100内使用IGP协议为OSPF ,如图运行动态路由协议
3.要求R1-R5之间启用MPLS Virtual Private Network; R6-R7之间启用MPLS Virtual Private Network;
4.将两条Virtual Private Network进行合并
5.R6-R7之间使用OSPF协议,要求R6-R7之间的私有IP地址通信优先使用MPLS
三、实验配置
1、规划IP地址
R1:
#
interface GigabitEthernet0/0/0
ip address 12.0.0.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 15.0.0.1 255.255.255.0
#
interface LoopBack0
ip address 192.168.1.1 255.255.255.0
#
R2:
#
interface GigabitEthernet0/0/0
ip address 12.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 23.0.0.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 26.0.0.2 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
R3:
#
interface GigabitEthernet0/0/0
ip address 23.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 34.0.0.1 255.255.255.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
R4:
#
interface GigabitEthernet0/0/0
ip address 34.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 45.0.0.2 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 47.0.0.2 255.255.255.0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
R5:
#
interface GigabitEthernet0/0/0
ip address 45.0.0.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 15.0.0.2 255.255.255.0
#
interface LoopBack0
ip address 192.168.2.5 255.255.255.0
#
R6:
#
interface GigabitEthernet0/0/2
ip address 26.0.0.1 255.255.255.0
#
interface LoopBack0
ip address 192.168.3.6 255.255.255.0
#
R7:
#
interface GigabitEthernet0/0/2
ip address 47.0.0.1 255.255.255.0
#
interface LoopBack0
ip address 192.168.4.7 255.255.255.0
#
2、动态路由协议配置
R1:
#
ospf 200 router-id 1.1.1.1
area 0.0.0.0
network 12.0.0.0 0.0.0.255
network 192.168.1.1 0.0.0.0
#
R2:
#
ospf 100 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 23.0.0.0 0.0.0.255
#
ospf 200 router-id 2.2.2.2 vpn-instance ia
area 0.0.0.0
network 12.0.0.0 0.0.0.255
#
rip 100 vpn-instance ip
version 2
network 26.0.0.0
#
bgp 100
router-id 2.2.2.2
peer 4.4.4.4 as-number 100
peer 4.4.4.4 connect-interface LoopBack0
#
R3:
#
ospf 100 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 23.0.0.0 0.0.0.255
network 34.0.0.0 0.0.0.255
#
R4:
#
ospf 100 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 34.0.0.0 0.0.0.255
#
ospf 200 router-id 4.4.4.4 vpn-instance ia
import-route bgp
area 0.0.0.0
network 45.0.0.0 0.0.0.255
#
rip 100 vpn-instance ip
version 2
network 47.0.0.0
import-route bgp
#
#
bgp 100
router-id 4.4.4.4
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
#
R5:
#
ospf 200 router-id 5.5.5.5
area 0.0.0.0
network 45.0.0.0 0.0.0.255
network 192.168.2.5 0.0.0.0
#
R6:
#
rip 100
version 2
network 192.168.3.0
network 26.0.0.0
#
R7:
#
rip 100
version 2
network 47.0.0.0
network 192.168.4.0
#
3、配置MPLS和路由重发布
R2:
#
ip vpn-instance ia
ipv4-family
route-distinguisher 200:1
vpn-target 200:1 export-extcommunity
vpn-target 200:1 import-extcommunity
#
ip vpn-instance ip
ipv4-family
route-distinguisher 100:1
vpn-target 100:1 export-extcommunity
vpn-target 100:1 import-extcommunity
#
mpls lsr-id 2.2.2.2
mpls
lsp-trigger all
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip binding vpn-instance ia
#
interface GigabitEthernet0/0/1
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
ip binding vpn-instance ip
#
#
bgp 100
ipv4-family unicast
undo synchronization
peer 4.4.4.4 enable
peer 4.4.4.4 next-hop-local
#
ipv4-family vpnv4
policy vpn-target
peer 4.4.4.4 enable
#
ipv4-family vpn-instance ia
import-route ospf 200
#
ipv4-family vpn-instance ip
import-route rip 100
#
ospf 200 router-id 2.2.2.2 vpn-instance ia
import-route bgp
#
rip 100 vpn-instance ip
import-route bgp
#
R4:
#
ip vpn-instance ia
ipv4-family
route-distinguisher 200:1
vpn-target 200:1 export-extcommunity
vpn-target 200:1 import-extcommunity
#
ip vpn-instance ip
ipv4-family
route-distinguisher 100:1
vpn-target 100:1 export-extcommunity
vpn-target 100:1 import-extcommunity
#
mpls lsr-id 4.4.4.4
mpls
lsp-trigger all
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 34.0.0.2 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip binding vpn-instance ia
#
interface GigabitEthernet0/0/2
ip binding vpn-instance ip
#
#
bgp 100
ipv4-family unicast
undo synchronization
peer 2.2.2.2 enable
peer 2.2.2.2 next-hop-local
#
ipv4-family vpnv4
policy vpn-target
peer 2.2.2.2 enable
#
ipv4-family vpn-instance ia
import-route ospf 200
#
ipv4-family vpn-instance ip
import-route rip 100
#
ospf 200 router-id 4.4.4.4 vpn-instance ia
import-route bgp
#
rip 100 vpn-instance ip
import-route bgp
#
查看PE端的路由表
R2:
R4:
查看CE端学习到的路由
R1:
R5:
R6:
R7:
4、合并
R2/R4:
#
ip vpn-instance ia
ipv4-family
vpn-target 200:1 100:1 export-extcommunity
vpn-target 200:1 100:1 import-extcommunity
#
5、R6-R7之间的私有IP地址通信优先使用MPLS(sham-link)
创建环回接口并划入VRF中
R2/4
#
interface LoopBack1
ip binding vpn-instance ia
ip address 100.1.1.1 255.255.255.255
#
#
interface LoopBack1
ip binding vpn-instance ia
ip address 100.1.1.2 255.255.255.255
#
将环回接口路由通告进入VPNV4 BGP 协议中
R2/4
#
ipv4-family vpn-instance ia
network 100.1.1.1 255.255.255.255
import-route ospf 200
#
#
ipv4-family vpn-instance ia
network 0.0.0.0
network 100.1.1.2 255.255.255.255
import-route ospf 200
#
查看学习到路由
启用OSPF 协议的sham-link
R2/4
#
ospf 200 router-id 2.2.2.2 vpn-instance ia
area 0.0.0.0
sham-link 100.1.1.1 100.1.1.2
#
#
ospf 200 router-id 4.4.4.4 vpn-instance ia
area 0.0.0.0
sham-link 100.1.1.2 100.1.1.1
#
查看sham-link
修改备份链路之间的开销值
R1/R5
#
interface GigabitEthernet0/0/1
ospf cost 33
#
#
interface GigabitEthernet0/0/1
ospf cost 33
#