实验步骤
配置IP地址
R1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[r1-GigabitEthernet0/0/0]int loopback0
[r1-LoopBack0]ip add 192.168.1.1 24
[r1-LoopBack0]int loopback1
[r1-LoopBack1]ip add 192.168.2.1 24
[r1-LoopBack1]int loopback3
[r1-LoopBack3]ip add 123.1.1.1 32
R2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 23.1.1.2 24
[r2-GigabitEthernet0/0/1]int loopback0
[r2-LoopBack0]ip add 2.2.2.2 24
[r2-LoopBack0]int loopback1
[r2-LoopBack1]ip add 123.1.1.2 32
R3
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 23.1.1.1 24
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
[r3-GigabitEthernet0/0/1]int loopback0
[r3-LoopBack0]ip add 3.3.3.3 24
[r3-LoopBack0]int loopback1
[r3-LoopBack1]ip add 123.1.1.3 32
R4
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 34.1.1.2 24
[r4-GigabitEthernet0/0/0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 45.1.1.2 24
[r4-GigabitEthernet0/0/1]int loop 0
[r4-LoopBack0]ip add 4.4.4.4 24
[r4-LoopBack0]int loop 1
[r4-LoopBack1]ip add 123.1.1.4 32
R5
[r5]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 45.1.1.1 24
[r5-GigabitEthernet0/0/0]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 56.1.1.1 24
[r5-GigabitEthernet0/0/1]int loop 0
[r5-LoopBack0]ip add 5.5.5.5 24
[r5-LoopBack0]int loop 1
[r5-LoopBack1]ip add 123.1.1.5 32
R6
[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 56.1.1.2 24
[r6-GigabitEthernet0/0/0]int g0/0/1
[r6-GigabitEthernet0/0/1]ip add 67.1.1.2 24
[r6-GigabitEthernet0/0/1]int loop 0
[r6-LoopBack0]ip add 6.6.6.6 24
[r6-LoopBack0]int loop 1
[r6-LoopBack1]ip add 123.1.1.6 32
R7
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 67.1.1.1 24
[r7-GigabitEthernet0/0/0]int loopback0
[r7-LoopBack0]ip add 172.16.1.1 24
[r7-LoopBack0]int loop1
[r7-LoopBack1]ip add 172.16.2.1 24
[r7-LoopBack1]int loop2
[r7-LoopBack2]ip add 123.1.1.7 32
R8-R11根据地址继续往下配即可。
使AS内部通
R1
[r1]rip 1
[r1-rip-1]version 2
[r1-rip-1]network 123.0.0.0
[r1-rip-1]network 192.168.1.0
[r1-rip-1]network 192.168.2.0
[r1-rip-1]network 12.0.0.0
R2
[r2]rip 1
[r2-rip-1]version 2
[r2-rip-1]network 12.0.0.0
[r2-rip-1]network 2.0.0.0
[r2-rip-1]network 123.0.0.0
R3
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 34.1.1.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 123.1.1.3 0.0.0.0
R4
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.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 45.1.1.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 123.1.1.5 0.0.0.0
R6
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 123.1.1.6 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 67.1.1.2 0.0.0.0
R7
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
R8-R11根据地址继续往下配即可。
建立BGP邻居
R1
[r1]bgp 100
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 123.1.1.2 as-number 100
[r1-bgp]peer 123.1.1.2 connect-interface LoopBack 3
R2
[r2]bgp 100
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 123.1.1.1 as-number 100
[r2-bgp]peer 123.1.1.1 connect-interface LoopBack 1
[r2-bgp]peer 23.1.1.1 as-number 101
R3
[r3]bgp 101
[r3-bgp]peer 23.1.1.2 as-number 100
[r3-bgp]peer 123.1.1.4 as-number 101
[r3-bgp]peer 123.1.1.4 connect-interface LoopBack 1
[r3-bgp]peer 123.1.1.5 as-number 101
[r3-bgp]peer 123.1.1.5 connect-interface LoopBack 1
R4
[r4]bgp 101
[r4-bgp]peer 123.1.1.3 as-number 101
[r4-bgp]peer 123.1.1.3 connect-interface LoopBack 1
[r4-bgp]peer 123.1.1.5 as-number 101
[r4-bgp]peer 123.1.1.5 connect-interface LoopBack 1
R5
(R5和R6使用环回接口建邻)
前提:R5和R6的环回可以相互ping通
所以先在R5和R6上写条静态路由
[r5]ip route-static 123.1.1.6 32 56.1.1.2
[r6]ip route-static 123.1.1.5 32 56.1.1.1
再使用环回建邻
注:由于EBGP之间的TTL默认为1,所以若使用环回建邻就必须修改TTL值
[r5]bgp 101
[r5-bgp]peer 123.1.1.3 as-number 101
[r5-bgp]peer 123.1.1.3 connect-interface LoopBack 1
[r5-bgp]peer 123.1.1.4 as-number 101
[r5-bgp]peer 123.1.1.4 connect-interface LoopBack 1
[r5-bgp]peer 123.1.1.6 as-number 102
[r5-bgp]peer 123.1.1.6 connect-interface LoopBack 1
[r5-bgp]peer 123.1.1.6 ebgp-max-hop 2
R6
[r6]bgp 102
[r6-bgp]peer 123.1.1.5 as-number 101
[r6-bgp]peer 123.1.1.5 connect-interface LoopBack 1
[r6-bgp]peer 123.1.1.5 ebgp-max-hop 2
[r6-bgp]peer 123.1.1.7 as-number 102
[r6-bgp]peer 123.1.1.7 connect-interface LoopBack 1
R7
[r7]bgp 102
[r7-bgp]peer 123.1.1.6 as-number 102
[r7-bgp]peer 123.1.1.6 connect-interface LoopBack 2
R8-R11根据地址继续往下配即可。