拓扑:
思路:
1.配IP,并在阴影区域运行ospf,在AR2和AR4相互建邻,同时字阴影区域开启mpls
2.创建vrf空间,赋值RD,RT(AR2,AR4)
3.AR1和AR5运行ospf,AR6和AR7运行rip
4.在AR2和AR4上将rip和osfp重发布到bgp
5.在AR7上rip协议中下放缺省,由于bgp不能传缺省,所以只能在AR4上获得缺省(在vrf-b中宣告缺省,即在AR2上获得缺省,在AR2上rip协议中下放缺省,使得AR6上可获得缺省)
6.在AR7上设置ACL和NAT,使其可以和isp通信
AR2上的vrf空间
ip vpn-instance a
ipv4-family
route-distinguisher 1:1
vpn-target 1:1 export-extcommunity
vpn-target 1:1 import-extcommunity
#
ip vpn-instance b
ipv4-family
route-distinguisher 2:2
vpn-target 2:2 export-extcommunity
vpn-target 2:2 import-extcommunity
#
AR2
interface GigabitEthernet0/0/0
ip binding vpn-instance a
ip address 192.168.2.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 23.1.1.2 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
ip binding vpn-instance b
ip address 192.168.2.2 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
bgp 1
peer 4.4.4.4 as-number 1
peer 4.4.4.4 connect-interface LoopBack0
#
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 //建立mp-bgp,可传输带有标签的路由
peer 4.4.4.4 enable
#
ipv4-family vpn-instance a
import-route ospf 2
#
ipv4-family vpn-instance b
import-route rip 1
#
ospf 1
area 0.0.0.0
network 2.2.2.0 0.0.0.255
network 23.1.1.0 0.0.0.255
#
ospf 2 vpn-instance a
import-route bgp
area 0.0.0.0
network 192.168.2.0 0.0.0.255
#
rip 1 vpn-instance b
default-route originate
network 192.168.2.0
import-route bgp
#
AR7
#
interface GigabitEthernet0/0/0
ip address 192.168.3.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 100.1.1.2 255.255.255.0
nat outbound 2000
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
ip address 192.168.4.2 255.255.255.0
#
rip 1
default-route originate
version 2
network 192.168.4.0
network 192.168.3.0
#
ip route-static 0.0.0.0 0.0.0.0 100.1.1.1
测试: