IPv4 32 位 全局公网
VPNV4 96位 64位RD+32位客户路由
VRF 32位 客户的路由接入
R3(config)#int lo 1
R3(config-if)#ip add 8.8.8.8 255.255.255.255 ----R3配置IP模拟器互联网公网IP
我们计划R6(分支)访问R3的lo0的互联网先经过R8(总部)再访问R3互联网
R3和R2之间激活BGP单播邻居用于传递互联网路由
1、R3和R2之间激活BGP单播邻居传递互联网路由,R2配置静态路由并引入BGP
R3(config)#router bgp 100
R3(config-router)#neighbor 22.1.1.1 remote-as 100
R3(config-router)#neighbor 22.1.1.1 update-source lo 0
R3(config-router)#address-family ipv4
R3(config-router-af)#neighbor 22.1.1.1 activate
R2(config)#router bgp 100
R2(config-router)#address-family 33.1.1.1 activ
R2(config-router)#address-family ipv4
R2(config-router-af)#neighbor 33.1.1.1 activate
R2(config)#ip route 66.1.1.1 255.255.255.255 serial 1/0
R2(config)#router bgp 100
R2(config-router)#address-family ipv4
R2(config-router-af)#redistribute static
此时R3回城R6的数据包是可达的。
2、R6从PE R2得到默认路由
R2(config)#router ospf 110 vrf cisco
R2(config-router)#default-information originate always
3、R2和R8访问8.8.8.8
R2(config)#ip route vrf cisco 8.8.8.8 255.255.255.255 88.1.1.1----下一跳到VRF的路由R8
R5(config)#router ospf 110 vrf cisco
R5(config-router)#default-information originate always --R5下发默认路由到R8
R5(config)#ip route vrf cisco 8.8.8.8 255.255.255.255 33.1.1.1 global --访问8.8.8.8下一跳为全局路由表中存在的地址,global把VRF路由引入到下一跳全局存在的地址
==================================================
客户端运行BGP
R2:router bgp 100
address-family ipv4 vrf cisco
network 2.2.2.2 mask 255.255.255.255
neighbor 26.1.1.6 remote-as 200
neighbor 26.1.1.6 activate
R6#sho run | s bgp
router bgp 200
bgp log-neighbor-changes
network 4.4.4.4 mask 255.255.255.255
network 6.6.6.6 mask 255.255.255.255
network 7.7.7.7 mask 255.255.255.255
network 9.9.9.9 mask 255.255.255.255
network 66.1.1.1 mask 255.255.255.255
neighbor 26.1.1.2 remote-as 100
R2(config-router-af)#neighbor 26.1.1.6 maximum-prefix 4 --接收最大4条路由
R6(config)#router bgp 200
R6(config-router)#network 4.4.4.4 ma 255.255.255.255--发布的4.4.4.4,R2告警
R6再增加一个环回口并发布进BGP
R6(config-router)#network 9.9.9.9 ma 255.255.255.255
超出4条路由邻居down掉:
R2(config-router-af)#neighbor 26.1.1.6 maximum-prefix 4 warning-only --只弹警告
P设备(R3)通常不用于控制层面,除非VPNV4的RR
减少配置,降低PE设备的压力
R3#sho run | s bgp
router bgp 100
bgp log-neighbor-changes
no bgp default ipv4-unicast
neighbor 22.1.1.1 remote-as 100
neighbor 22.1.1.1 update-source Loopback0
neighbor 44.1.1.1 remote-as 100
neighbor 44.1.1.1 update-source Loopback0
neighbor 55.1.1.1 remote-as 100
neighbor 55.1.1.1 update-source Loopback0
address-family ipv4
neighbor 22.1.1.1 activate
exit-address-family
address-family vpnv4
neighbor 22.1.1.1 activate
neighbor 22.1.1.1 send-community extended
neighbor 22.1.1.1 route-reflector-client
neighbor 44.1.1.1 activate
neighbor 44.1.1.1 send-community extended
neighbor 44.1.1.1 route-reflector-client
neighbor 55.1.1.1 activate
neighbor 55.1.1.1 send-community extended
neighbor 55.1.1.1 route-reflector-client
R2#sho run | s bgp
redistribute bgp 100 subnets
router bgp 100
bgp log-neighbor-changes
no bgp default ipv4-unicast
neighbor 33.1.1.1 remote-as 100
neighbor 33.1.1.1 update-source Loopback0
neighbor 55.1.1.1 remote-as 100
neighbor 55.1.1.1 update-source Loopback0
!
address-family ipv4
redistribute static
neighbor 33.1.1.1 activate
exit-address-family
!
address-family vpnv4
neighbor 33.1.1.1 activate
neighbor 33.1.1.1 send-community extended
exit-address-family
!
address-family ipv4 vrf cisco
network 2.2.2.2 mask 255.255.255.255
redistribute ospf 110 match internal external 1 external 2 nssa-external 1 nssa-external 2
neighbor 26.1.1.6 remote-as 200
neighbor 26.1.1.6 activate
neighbor 26.1.1.6 as-override ---EBGP默认不会接收与本AS一样的路由,改写AS与本AS一样为100
另外一种方法在R4使用Allowas-in允许接收与本身相同AS的路由
R7(config-router)#neighbor 47.1.1.4 allowas-in 1
SOO用于防环
============================================
R4(config)#access-list 10 permit 6.6.6.6 0.0.0.0
R4(config)#route-map IMPORT
R4(config-route-map)#match ip address 10
R4(config)#ip vrf cisco
R4(config-vrf)#import map IMPORT ---在收到所有的VPNV4路由之后进行过滤,本质是对放入的VRF路由条目进行过滤,R7此时只通过R4接收6.6.6.6的路由
R4(config)#route-map EXPORT
R4(config-route-map)#match ip address 10
R4(config-route-map)#set extcommunity rt 44:44 additive --增加RT
R4(config)#ip vrf cisco
R4(config-vrf)#export map EXPORT
如果对方R7的RT的import设置44:44或25:25,都可以收取R4的路由!
欢迎关注和转发,更多精彩内容下期继续分享!
閱讀更多 專注分享網絡技術 的文章