目标:
1、首先需要基于该与拓扑图对172.16.0.0/16进行子网划分:
题中一共需要八个网段的环回和一个骨干链路共8个网段;
172.16.0.0 20 骨干 再分为八个:
172.16.0.0 30 172.16.0.4 30 172.16.0.8 30 172.16.0.12 30 172.16.0.16 30
172.16.0.20 30 172.16.0. 24 30 172.16.0.28 30
172.16.16.0 20 r1 ---172.16.16.0 21 (用于BGP的建立) 172.16.24.0 21(客户)
172.16.32.0 20 r2 ---172.16.32.0 21 (用于BGP的建立) 172.16.40.0 21(客户)
172.16.48.0 20 r3 ---172.16.48.0 21 (用于BGP的建立) 172.16.56.0 21(客户)
172.16.64.0 20 r4 ---172.16.64.0 21 (用于BGP的建立) 172.16.72.0 21(客户)
172.16.80.0 20 r5 ---172.16.80.0 21 (用于BGP的建立) 172.16.88.0 21(客户)
172.16.96.0 20 r6 ---172.16.96.0 21 (用于BGP的建立) 172.16.102.0 21(客户)
172.16.112.0 20 r7 ---172.16.112.0 21 (用于BGP的建立) 172.16.120.0 21(客户)
172.16.128.0 20 r8 ---172.16.128.0 21 (用于BGP的建立) 172.16.130.0 21(客户)
172.16.144.0 20、172.16.160.0 20、172.16.176.0 20、172.16.192.0 20、172.16.208.0 20、172.16.224.0 20、172.16.240.0 20(保留)
2、首先为每个路由器配置环回和接口ip
r1:
[r1]interface lo0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1-LoopBack0]int gi 0/0/0
[r1-GigabitEthernet0/0/0]ip add 172.16.0.1 30
r2:
[r2-LoopBack0]ip add 172.16.32.1 21
[r2-LoopBack0]int lo1
[r2-LoopBack1]ip add 172.16.40.1 21
[r2-LoopBack1]int gi 0/0/0
[r2-GigabitEthernet0/0/0]ip add 172.16.0.2 30
[r2-GigabitEthernet0/0/0]int gi 0/0/1
[r2-GigabitEthernet0/0/1]ip add 172.16.0.5 30
[r2-GigabitEthernet0/0/1]int gi 0/0/2
[r2-GigabitEthernet0/0/2]ip add 172.16.0.13 30
r3:
[r3-LoopBack0]ip add 172.16.48.1 21
[r3-LoopBack0]int lo1
[r3-LoopBack1]ip add 172.16.56.1 21
[r3-LoopBack1]int gi 0/0/0
[r3-GigabitEthernet0/0/0]ip add 172.16.0.6 30
[r3-GigabitEthernet0/0/0]int gi 0/0/1
[r3-GigabitEthernet0/0/1]ip add 172.16.0.9 30
r4:
[r4-LoopBack0]ip add 172.16.64.1 21
[r4-LoopBack0]int lo1
[r4-LoopBack1]ip add 172.16.72.1 21
[r4-LoopBack1]int gi 0/0/0
[r4-GigabitEthernet0/0/0]ip add 172.16.0.10 30
[r4-GigabitEthernet0/0/0]int gi 0/0/2
[r4-GigabitEthernet0/0/2]ip add 172.16.0.25 30
r5:
[r5]int lo0
[r5-LoopBack0]ip add 172.16.80.1 21
[r5-LoopBack0]int lo1
[r5-LoopBack1]ip add 172.16.88.1 21
[r5-LoopBack1]int gi 0/0/0
[r5-GigabitEthernet0/0/0]ip add 172.16.0.14 30
[r5-GigabitEthernet0/0/0]int gi 0/0/1
[r5-GigabitEthernet0/0/1]ip add 172.16.0.17 30
r6:
[r6]int lo0
[r6-LoopBack0]ip add 172.16.96.1 21
[r6-LoopBack0]int lo1
[r6-LoopBack1]ip add 172.16.104.1 21
[r6-LoopBack1]int gi 0/0/0
[r6-GigabitEthernet0/0/0]ip add 172.16.0.18 30
[r6-GigabitEthernet0/0/0]int gi 0/0/1
[r6-GigabitEthernet0/0/1]ip add 172.16.0.21 30
r7:
[r7]int lo0
[r7-LoopBack0]ip add 172.16.112.1 21
[r7-LoopBack0]int lo1
[r7-LoopBack1]ip add 172.16.120.1 21
[r7-LoopBack1]int gi 0/0/0
[r7-GigabitEthernet0/0/0]ip add 172.16.0.22 30
[r7-GigabitEthernet0/0/0]int gi 0/0/1
[r7-GigabitEthernet0/0/1]ip add 172.16.0.29 30
[r7-GigabitEthernet0/0/1]int gi 0/0/2
[r7-GigabitEthernet0/0/2]ip add 172.16.0.26 30
r8:
[r8]int lo0
[r8-LoopBack0]ip add 8.8.8.8 24
[r8-LoopBack0]int gi 0/0/0
[r8-GigabitEthernet0/0/0]ip add 172.16.0.30 30
3、进行OSPF的宣告创造IGP环境
注意:在宣告OSPF时全部路由器统一宣告环回lo1,不用宣告lo0
下面进行OSPF的宣告
r2:
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 172.16.40.1 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 172.16.0.4 255.255.255.252
[r2-ospf-1-area-0.0.0.0]network 172.16.0.12 255.255.255.252
network 172.16.0.0 0.0.255.255
r3:
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 172.16.56.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 172.16.0.4 255.255.255.252
[r3-ospf-1-area-0.0.0.0]network 172.16.0.8 255.255.255.252
network 172.16.0.0 0.0.255.255
r4:
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 172.16.72.1 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 172.16.0.8 255.255.255.252
[r4-ospf-1-area-0.0.0.0]
[r4-ospf-1-area-0.0.0.0]network 172.16.0.24 255.255.255.252
network 172.16.0.0 0.0.255.255
r5:
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 172.16.88.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 172.16.0.12 255.255.255.252
[r5-ospf-1-area-0.0.0.0]network 172.16.0.16 255.255.255.252
network 172.16.0.0 0.0.255.255
r6:
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 172.16.104.1 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 172.16.0.16 255.255.255.252
[r6-ospf-1-area-0.0.0.0]network 172.16.0.20 255.255.255.252
network 172.16.0.0 0.0.255.255
r7:
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 172.16.120.1 0.0.0.0
[r7-ospf-1-area-0.0.0.0]network 172.16.0.20 255.255.255.252
[r7-ospf-1-area-0.0.0.0]network 172.16.0.24 255.255.255.252
network 172.16.0.0 0.0.255.255
现在OSPF已经宣告完毕了,并且检查ospf表没有问题
现在需要将用户环回的掩码改为21位修改该环回的接口类型:
[r2]int lo 1
[r2-LoopBack1]ospf network-type broadcast
[r3]int lo1
[r3-LoopBack1] ospf network-type broadcast
[r4]int lo1
[r4-LoopBack1]ospf network-type broadcast
[r5]int lo1
[r5-LoopBack1]ospf network-type broadcast
[r6]int lo1
[r6-LoopBack1]ospf network-type broadcast
[r7]int lo1
[r7-LoopBack1]ospf network-type broadcast
4、现在就可以在拓扑中建立BGP了
思路:
AS1:r1
AS2:r2~r7 ---AS64512: r2/r3/r4 ---AS64513:r5/r6/r7
AS3:r8
r1与r2建立EBGP
r2-r3、r3-r4、r5-r6、r6-r7建立IBGP
r2-r5、r4-r7建立EBGP(实际还是IBGP)
具体配置:
r1:
[r1-bgp]peer 172.16.0.2 as-number 2
r2:
[r2]bgp 64512
[r2-bgp]router-id 2.2.2.2
[r2-bgp]confederation id 2
[r2-bgp]confederation peer-as 64513
[r2-bgp]peer 172.16.48.1 as-number 64512
[r2-bgp]peer 172.16.48.1 connect-interface LoopBack 0
[r2-bgp]peer 172.16.80.1 as-number 64513
[r2-bgp]peer 172.16.80.1 connect-interface LoopBack 0
[r2-bgp]peer 172.16.80.1 ebgp-max-hop 2
[r2-bgp]peer 172.16.0.1 as 1
r3:
[r3]bgp 64512
[r3-bgp]router-id 3.3.3.3
[r3-bgp]confederation id 2
[r3-bgp]peer 172.16.32.1 as-number 64512
[r3-bgp]peer 172.16.32.1 connect-interface LoopBack 0
[r3-bgp]peer 172.16.64.1 as-number 64512
[r3-bgp]peer 172.16.64.1 connect-interface LoopBack 0
r4:
[r4]bgp 64512
[r4-bgp]router-id 4.4.4.4
[r4-bgp]confederation id 2
[r4-bgp]confederation peer-as 64513
[r4-bgp]peer 172.16.48.1 as 64512
[r4-bgp]peer 172.16.48.1 connect-interface LoopBack 0
[r4-bgp]peer 172.16.112.1 as 64513
[r4-bgp]peer 172.16.112.1 connect-interface LoopBack 0
[r4-bgp]peer 172.16.112.1 ebgp-max-hop 2
r5:
[r5]bgp 64513
[r5-bgp]router-id 5.5.5.5
[r5-bgp]confederation id 2
[r5-bgp]confederation peer-as 64512
[r5-bgp]peer 172.16.32.1 as-number 64512
[r5-bgp]peer 172.16.32.1 connect-interface LoopBack 0
[r5-bgp]peer 172.16.32.1 ebgp-max-hop 2
[r5-bgp]peer 172.16.96.1 as 64513
[r5-bgp]peer 172.16.96.1 connect-interface LoopBack 0
r6;
[r6]bgp 64513
[r6-bgp]router-id 6.6.6.6
[r6-bgp]confederation id 2
[r6-bgp]peer 172.16.80.1 as 64513
[r6-bgp]peer 172.16.80.1 connect-interface LoopBack 0
[r6-bgp]peer 172.16.112.1 as 64513
[r6-bgp]peer 172.16.112.1 connect-interface LoopBack 0
r7:
[r7]bgp 64513
[r7-bgp]route-select
[r7-bgp]router-id 7.7.7.7
[r7-bgp]confederation id 2
[r7-bgp]confederation peer-as 64512
[r7-bgp]peer 172.16.96.1 as 64513
[r7-bgp]peer 172.16.96.1 connect-interface LoopBack 0
[r7-bgp]peer 172.16.64.1 as 64512
[r7-bgp]peer 172.16.64.1 connect-interface LoopBack 0
[r7-bgp]peer 172.16.64.1 ebgp-max-hop 2
[r7-bgp]peer 172.16.0.30 as 3
r8:
[r8]bgp 3
[r8-bgp]router-id 8.8.8.8
[r8-bgp]peer 172.16.0.29 as 2
现在BGP已经建立完成了
5、现在在r1和r8上宣告自己的环回
r1的宣告:
[r1-bgp]network 1.1.1.1 24
[r8-bgp]network 8.8.8.8 24
这里只有r2和r7上是优的所以修改下一跳:
[r2-bgp]peer 172.16.48.1 next-hop-local
[r2-bgp]peer 172.16.80.1 next-hop-local
这时r3和r5都学习到了r1的宣告但是一位IBGP水平分割的原因r3无法将bgp信息发送给r4,r6无法将bgp传递给r7
解决方案使用路由反射器
r3:
[r3-bgp]peer 172.16.64.1 reflect-client
r6:
[r6-bgp]peer 172.16.112.1 reflect-client
宣告完成后r4和r7就学习到了r1的路由
r8的宣告:
[r8-bgp]network 8.8.8.0 24
进行下一跳的宣告
[r7-bgp]peer 172.16.96.1 next-hop-local
[r7-bgp]peer 172.16.64.1 next-hop-local
现在r1的环回了就可以ping通r8的环回了
6、可以建立一个空接口让AS2内部的环回可以和AS1/AS3的环回进行联系
[r2]ip route-static 172.16.0.0 21 NULL 0
[r2]bgp 64512
[r2-bgp]network 172.16.0.0 21
[r7]ip route-static 172.16.0.0 21 NULL 0
[r7]bgp 64513
[r7-bgp]network 172.16.0.0 21