路由综合实验
一、整个AS2的IP地址为172.16.0.0/16,请合理划分
As64512:
172.16.0.0/18
172.16.0.0/24 ---骨干链路(P2P骨干)/30
172.16.0.0/30
172.16.0.4/30
172.16.0.8/30
...
172.16.0.252/30
172.16.1.0/24 ---用户
172.16.2.0/24 ---用户
172.16.3.0/24 ---用户
...
172.16.63.0/24
As64513:
172.16.64.0/18
172.16.64.0/24 ---骨干链路(P2P骨干)/30
172.16.64.0/30
172.16.64.4/30
172.16.64.8/30
...
172.16.64.252/30
172.16.65.0/24 ---用户
172.16.66.0/24 ---用户
172.16.67.0/24 ---用户
...
172.16.127.0/24
172.16.128.0/18
172.16.128.0/24 ---骨干链路(P2P骨干)/30
172.16.128.0/30 ---联邦As骨干链路
172.16.128.4/30 ---联邦As骨干链路
172.16.128.8/30
...
172.16.128.0/30
172.16.129.0/24
172.16.130.0/24
...
172.16.191.0/24
172.16.192.0/18 ---保留
二、As2内运行ospf,使内网可达
[r2-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.0.3
[r2-ospf-1-area-0.0.0.0]network 172.16.128.0 0.0.0.3
(不能宣告公有As之间的网段,其他同理)
三、使用BGP协议让整个网络所有设备的环回可以互相访问
[r1]bgp 1
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.0.0.2 as-number 2
[r1-bgp]network 1.1.1.0 24
[r2]bgp 64512(联邦As号,私有As号)
[r2-bgp]router-id 2.2.2.2
[r2-bgp]confederation id 2(声明公有As号)
[r2-bgp]peer 12.0.0.1 as-number 1
[r2-bgp]peer 172.16.0.2 next-hop-local(修改下一跳指向本设备,去除bgp的as-by-as
(路径属性不变)的影响,保证下一跳可达)
(也可以使用环回建邻,不过要修改建邻接口:[r2-bgp]peer 12.0.0.1 connect-interface LoopBack 0,
如果是环回建立EBGP对等体,还有增加ttl值:[r2-bgp]peer 12.0.0.1 ebgp-max-hop ,默认为1,环回
要经过2个设备,至少设置为2)
其他同理
[r3-bgp]peer 172.16.0.1 reflect-client (因为bgp的水平分割,设置r3为反射器,r1为客户,
让r2的路由得以发给r4)r6同理
[r2-bgp]confederation peer-as 64513(建立联盟EBGP对等体)
[r2-bgp]peer 172.16.128.2 as-number 64513
[r5-bgp]confederation peer-as 64512
[r5-bgp]peer 172.16.128.1 as-number 64512
[r2-bgp]peer 172.16.128.2 next-hop-local
四、减少路由条目数量,避免环路出现
[r2-bgp]aggregate 172.16.0.0 16 as-set detail-suppressed(聚合,减少路由,设置继承as_path属性,
防环,默认不继承,并抑制明细路由,默认不抑制,会自动
生成一个指向空接口的汇总网段,防环)
[r7-bgp]aggregate 172.16.0.0 16 as-set detail-suppressed
五、让R1和R8未宣告在BGP中的两个环回互相通讯
构建隧道,使用gre协议(vpn)
[r1]int Tunnel 0/0/0
[r1-Tunnel0/0/0]ip add 192.168.3.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre
[r1-Tunnel0/0/0]source 1.1.1.1
[r1-Tunnel0/0/0]destination 8.8.8.8
[r8]interface Tunnel 0/0/0
[r8-Tunnel0/0/0]ip add 192.168.3.2 24
[r8-Tunnel0/0/0]tunnel-protocol gre
[r8-Tunnel0/0/0]source 8.8.8.8
[r8-Tunnel0/0/0]destination 1.1.1.1
[r1]ip route-static 0.0.0.0 0 192.168.3.2
[r8]ip route-static 0.0.0.0 0 192.168.3.1