要求
1,AS1存在两个环回,一个地址为192.168.1.0/24该地址不能在任何协议中宣告
AS3中存在两个环回,一个地址为192.168.2.0/24该地址不能在任何协议中宣告,最终要求这两个环回可以互相通讯、
AS1的另一个环回为10.0.0.0/24,AS3的另一个环回为11.0.0.0/24
2,整个AS2的IP地址为172.16.0.0/16,请合理划分
3,AS间的骨干链路IP地址随意定制
4,使用BGP协议让整个网络所有设备的环回可以互相访问
5,减少路由条目数量,避免环路出现
先把相关路由的IP配置好
并在AS2区域中,A2-A7Z中运行OSPF协议
整个AS2的IP地址为172.16.0.0/16,按照IBGP进行子网划分
设备 | 环回 |
AR2 | 172.16.2.1 24 |
AR3 | 172.16.3.1 24 |
AR4 | 172.16.3.1 24 |
AR5 | 172.16.4.1 24 |
AR6 | 172.16.5.1 24 |
AR7 | 172.16.6.1 24 |
网段 | |
R2-R3 | 172.16.1.0 29 |
R3-R4 | 172.16.1.8 29 |
R5-R6 | 172.16.1.32 29 |
R6-R7 | 172.16.1.24 29 |
R2-R5 | 172.16.1.40 29 |
R4-R7 | 172.16.1.16 29 |
运行OSPF,并宣告(可以一次性宣告)
例如在R2,其他也可以这样
ospf 100 router-id 2.2.2.2
area 0
network 172.16.0.0 0.0.255.255
具体配置
BGP对等体建立
[r1]bgp 1
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as 2
[r2]bgp 64512
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.1.1.1 as 1
[r2-bgp]confederation id 2
[r2-bgp]peer 172.16.3.1
[r2-bgp]peer 172.16.3.1 as 64512
[r2-bgp]peer 172.16.3.1 connect-interface LoopBack 0
[r2-bgp]peer 172.16.3.1 next-hop-local
[r2-bgp]confederation peer-as 64513
[r2-bgp]peer 172.16.7.1 as 64513
[r2-bgp]peer 172.16.7.1 connect-interface LoopBack 0
[r2-bgp]peer 172.16.7.1 next-hop-local
[r2-bgp]peer 172.16.7.1 ebgp-max-hop
[r3]bgp 64512
[r3-bgp]router-id 3.3.3.3
[r3-bgp]confederation id 2
[r3-bgp]peer 172.16.2.1 as 64512
[r3-bgp]peer 172.16.2.1 connect-interface LoopBack 0
[r3-bgp]peer 172.16.2.1 next-hop-local
[r3-bgp]peer 172.16.4.1 as 64512
[r3-bgp]peer 172.16.4.1 connect-interface LoopBack 0
[r3-bgp]peer 172.16.4.1 next-hop-local
R4
bgp 64512
router-id 4.4.4.4
confederation id 2
confederation peer-as 64513
peer 172.16.3.1 as-number 64512
peer 172.16.3.1 connect-interface LoopBack0
peer 172.16.5.1 as-number 64513
peer 172.16.5.1 ebgp-max-hop 255
peer 172.16.5.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 172.16.3.1 enable
peer 172.16.3.1 next-hop-local
peer 172.16.5.1 enable
peer 172.16.5.1 next-hop-local
#
R5
bgp 64513
router-id 5.5.5.5
confederation id 2
confederation peer-as 64512
peer 172.16.2.1 as-number 64512
peer 172.16.2.1 ebgp-max-hop 255
peer 172.16.2.1 connect-interface LoopBack0
peer 172.16.6.1 as-number 64513
peer 172.16.6.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 172.16.2.1 enable
peer 172.16.6.1 enable
peer 172.16.6.1 next-hop-local
#
R6
bgp 64513
router-id 6.6.6.6
confederation id 2
peer 172.16.5.1 as-number 64513
peer 172.16.5.1 connect-interface LoopBack0
peer 172.16.7.1 as-number 64513
peer 172.16.7.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 172.16.5.1 enable
peer 172.16.5.1 next-hop-local
peer 172.16.7.1 enable
peer 172.16.7.1 next-hop-local
R7
#
bgp 64513
router-id 7.7.7.7
confederation id 2
confederation peer-as 64512
peer 78.1.1.2 as-number 3
peer 172.16.4.1 as-number 64512
peer 172.16.4.1 ebgp-max-hop 255
peer 172.16.4.1 connect-interface LoopBack0
peer 172.16.6.1 as-number 64513
peer 172.16.6.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 172.16.0.0 255.255.248.0
peer 78.1.1.2 enable
peer 172.16.4.1 enable
peer 172.16.4.1 next-hop-local
peer 172.16.6.1 enable
peer 172.16.6.1 next-hop-local
#
R8
#
bgp 3
router-id 8.8.8.8
peer 78.1.1.1 as-number 2
#
ipv4-family unicast
undo synchronization
network 11.0.0.0 255.255.255.0
peer 78.1.1.1 enable
#
因为 AS64512 有三台设备 由于水平分割 不会从IBGP对等体学来的路由进行转发,所有要用到路由反射器(RR)
1) RR可以将客户发的IBGP路由,发给自己的其他客户和非客户
2) RR将非客户发的IBGP路由,发给自己的客户,不发给非客户
有个口诀“非非不发”
R3将R2作为它的客户,这样可以将R2发来的IBGP路由,发给R4
[r3-bgp]peer 172.16.2.1 reflect-client
R6将R5作为它的客户,这样可以将R5发来的IBGP路由,发给R7
[r6-bgp]peer 172.16.7.1 reflect-client
减少路由条目数量
[r2]ip route-static 172.16.0.0 21 null 0
[r2]bgp 64512
[r2-bgp]net 172.16.0.0 21
[r7]ip route-static 172.16.0.0 21 null 0
[r7]bgp 64513
[r7-bgp]net 172.16.0.0 21
R1宣告路由
[r1]bgp 1
[r1-bgp]net 10.0.0.0 24
R8宣告路由
[r8]bgp 3
[r8-bgp]net 11.0.0.0 24
因为其中有一个环回接口可以宣告,可以用VPN技术,gre,建立Tunnel隧道,使得没法宣告的环回直接也可以ping通
[r1]interface Tunnel 0/0/0
[r1-Tunnel0/0/0]ip add 192.168.10.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre
[r1-Tunnel0/0/0]source 10.0.0.1
[r1-Tunnel0/0/0]destination 11.0.0.1
[r1]ip route-static 192.168.2.0 24 192.168.10.2---指向R8的环回
[r8]interface Tunnel 0/0/0
[r8-Tunnel0/0/0]ip add 192.168.10.2 24
[r8-Tunnel0/0/0]tunnel-protocol gre
[r8-Tunnel0/0/0]source 11.0.0.1
[r8-Tunnel0/0/0]destination 10.0.0.1
[r8]ip route-static 192.168.1.0 24 192.168.10.1
测试
在R1和R8上,用两个不宣告的环回互相ping,可以看出路径,走的是tunnel隧道
在R1上ping R7环回
R2环回上ping R6环回