1.配置IP
r1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.100.9 30
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 10.10.10.41 30
[r1]int g0/0/2
[r1-GigabitEthernet0/0/2]ip add 192.168.100.17 30
[r1]int g1/0/0
[r1-GigabitEthernet1/0/0]ip add 10.10.10.1 30
[r1]int g2/0/0
[r1-GigabitEthernet2/0/0]ip add 10.10.10.5 30
[r1]int lo0
[r1-LoopBack0]ip add 1.1.1.1 32
r2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0] ip address 192.168.100.13 30
[r2]int g0/0/1
[r2-GigabitEthernet0/0/1] ip address 10.10.10.42 30
[r2]int g0/0/2
[r2-GigabitEthernet0/0/2] ip address 192.168.100.5 30
[r2]int g1/0/0
[r2-GigabitEthernet1/0/0] ip address 10.10.10.13 30
[r2]int g2/0/0
[r2-GigabitEthernet1/0/0] ip address 10.10.10.9 30
[r2]int lo0
[r2-LoopBack0]ip address 2.2.2.2 32
r3
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0] ip address 192.168.100.13 30
[r2]int g0/0/1
[r2-GigabitEthernet0/0/1] ip address 10.10.10.42 30
[r2]int g0/0/2
[r2-GigabitEthernet0/0/2] ip address 192.168.100.5 30
[r2]int g1/0/0
[r2-GigabitEthernet1/0/0] ip address 10.10.10.13 30
[r2]int g2/0/0
[r2-GigabitEthernet1/0/0] ip address 10.10.10.9 30
[r2]int lo0
[r2-LoopBack0]ip address 2.2.2.2 32
r4
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip address 192.168.100.14 30
[r4]int g0/0/1
[r4-GigabitEthernet0/0/1]ip address 192.168.2.254 30
[r4]int g0/0/2
[r4-GigabitEthernet0/0/2]ip address 192.168.100.2 30
[r4]int g1/0/0
[r4-GigabitEthernet1/0/0]ip address 192.168.100.18 30
r5
[r5]int g0/0/0
[r5-GigabitEthernet0/0/0] ip address 10.10.10.2 30
[r5]int g0/0/1
[r5-GigabitEthernet0/0/1] ip address 10.10.10.10 30
[r5]int g0/0/2
[r5-GigabitEthernet0/0/2] ip address 10.10.10.21 30
[r5]int g1/0/0
[r5-GigabitEthernet1/0/0] ip address 10.10.10.17 30
[r5]int lo0
[r5-LoopBack0]ip address 5.5.5.5 32
r6
[r6]int g0/0/0
[r6-GigabitEthernet0/0/0] ip address 10.10.10.14 30
[r6]int g0/0/1
[r6-GigabitEthernet0/0/1] ip address 10.10.10.6 30
[r6]int g0/0/2
[r6-GigabitEthernet0/0/2] ip address 10.10.10.25 30
[r6]int g1/0/0
[r6-GigabitEthernet1/0/0] ip address 10.10.10.18 30
[r6]int lo0
[r6-LoopBack0]ip address 6.6.6.6 32
r7
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0] ip address 10.10.10.22 30
[r7]int g0/0/1
[r7-GigabitEthernet0/0/1] ip address 10.10.10.26 30
[r7]int g0/0/2
[r7-GigabitEthernet0/0/2] ip address 10.10.10.29 30
[r7]int g1/0/0
[r7-GigabitEthernet1/0/0] ip address 10.10.10.33 30
[r7]int lo0
[r7-LoopBack0]ip address 7.7.7.7 32
r8
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0] ip address 10.10.10.22 30
[r7]int g0/0/1
[r7-GigabitEthernet0/0/1] ip address 10.10.10.26 30
[r7]int g0/0/2
[r7-GigabitEthernet0/0/2] ip address 10.10.10.29 30
[r7]int g1/0/0
[r7-GigabitEthernet1/0/0] ip address 10.10.10.33 30
[r7]int lo0
[r7-LoopBack0]ip address 7.7.7.7 32
r9
[r9]int g0/0/0
[r9-GigabitEthernet0/0/0] ip address 10.10.10.38 30
[r9]int g0/0/1
[r9-GigabitEthernet0/0/1] ip address 192.168.200.2 30
[r9]int lo0
[r9-LoopBack0]ip address 9.9.9.9 32
r10
[r10]int g0/0/0
[r10-GigabitEthernet0/0/0]ip add 192.168.200.1 30
[r10-GigabitEthernet0/0/1]int g0/0/1.1
[r10-GigabitEthernet0/0/1.1]dot1q termination vid 10
[r10-GigabitEthernet0/0/1.1]ip add 192.168.3.254 24
[r10-GigabitEthernet0/0/1.1]arp broadcast enable
[r10-GigabitEthernet0/0/1.1]int g0/0/1.2
[r10-GigabitEthernet0/0/1.2]dot1q termination vid 20
[r10-GigabitEthernet0/0/1.2]ip add 192.168.4.254 24
[r10-GigabitEthernet0/0/1.2]arp broadcast enable
[r10-GigabitEthernet0/0/1.2]int g0/0/2
[r10-GigabitEthernet0/0/2]int lo0
[r10-LoopBack0]ip add 1.1.1.1 24
2.划分vlan
[sw4]undo info-center enable
[sw4]vlan batch 10 20
[sw4]int g0/0/2
[sw4-GigabitEthernet0/0/2]port link-type access
[sw4-GigabitEthernet0/0/2]port default vlan 20
[sw4-GigabitEthernet0/0/2]int g0/0/3
[sw4-GigabitEthernet0/0/3]port link-type access
[sw4-GigabitEthernet0/0/3]port default vlan 10
[sw4-GigabitEthernet0/0/3]int g0/0/1
[sw4-GigabitEthernet0/0/1]port link-type trunk
[sw4-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
4.配置ospf
r1
[r1]ospf 100 router-id 1.1.1.1
[r1-ospf-100]area 0.0.0.0
[r1-ospf-100-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[r1-ospf-100-area-0.0.0.0]network 192.168.100.9 0.0.0.0
[r1-ospf-100-area-0.0.0.0]network 192.168.100.17 0.0.0.0
ospf重发布类型改为type-1
[r1-ospf-100]import-route bgp type 1
r2
[r2]ospf 100 router-id 2.2.2.2
[r2-ospf-100]area 0.0.0.0
[r2-ospf-100-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r2-ospf-100-area-0.0.0.0]network 192.168.100.5 0.0.0.0
[r2-ospf-100-area-0.0.0.0]network 192.168.100.13 0.0.0.0
ospf重发布改为type-1
[r2-ospf-100]import-route bgp type 1
r3
[r3]ospf 100 router-id 3.3.3.3
[r3-ospf-100]area 0.0.0.0
[r3-ospf-100-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r3-ospf-100-area-0.0.0.0]network 192.168.100.1 0.0.0.0
[r3-ospf-100-area-0.0.0.0]network 192.168.100.6 0.0.0.0
[r3-ospf-100-area-0.0.0.0]network 192.168.100.10 0.0.0.0
[r3-ospf-100-area-0.0.0.0]network 192.168.1.254 0.0.0.0
r4
[r4]ospf 100 router-id 4.4.4.4
[r4-ospf-100]area 0.0.0.0
[r4-ospf-100-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[r4-ospf-100-area-0.0.0.0]network 192.168.100.2 0.0.0.0
[r4-ospf-100-area-0.0.0.0]network 192.168.100.14 0.0.0.0
[r4-ospf-100-area-0.0.0.0]network 192.168.100.18 0.0.0.0
[r4-ospf-100-area-0.0.0.0]network 192.168.2.254 0.0.0.0
r5
[r5]ospf 10 router-id 5.5.5.5
[r5-ospf-10-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[r5-ospf-10-area-0.0.0.0]network 10.10.10.17 0.0.0.0
[r5-ospf-10-area-0.0.0.0]network 10.10.10.21 0.0.0.0
r6
[r6]ospf 10 router-id 6.6.6.6
[r6-ospf-10]area 0.0.0.0
[r6-ospf-10-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[r6-ospf-10-area-0.0.0.0]network 10.10.10.18 0.0.0.0
[r6-ospf-10-area-0.0.0.0]network 10.10.10.25 0.0.0.0
r7
[r7]ospf 10 router-id 7.7.7.7
[r7-ospf-10-area-0.0.0.0]network 7.7.7.7 0.0.0.0
[r7-ospf-10-area-0.0.0.0]network 10.10.10.22 0.0.0.0
[r7-ospf-10-area-0.0.0.0]network 10.10.10.26 0.0.0.0
[r7-ospf-10-area-0.0.0.0]network 10.10.10.29 0.0.0.0
[r7-ospf-10-area-0.0.0.0]network 10.10.10.33 0.0.0.0
r8
[r8]ospf 10 router-id 8.8.8.8
[r8-ospf-10]area 0
[r8-ospf-10-area-0.0.0.0]network 8.8.8.8 0.0.0.0
[r8-ospf-10-area-0.0.0.0]network 10.10.10.30 0.0.0.0
[r8-ospf-10-area-0.0.0.0]network 10.10.10.34 0.0.0.0
r9
[r9]ospf 200 router-id 9.9.9.9
[r9-ospf-200]area 0
[r9-ospf-200-area-0.0.0.0]network 192.168.200.2 0.0.0.0
[r9-ospf-200]import-route
ospf重发布改为type-1
[r9-ospf-200]import-route bgp type 1
r10
[r10]ospf 200 router-id 10.10.10.10
[r10-ospf-200]area 0
[r10-ospf-200-area-0.0.0.0]network 192.168.200.1 0.0.0.0
[r10-ospf-200-area-0.0.0.0]network 192.168.3.254 0.0.0.0
[r10-ospf-200-area-0.0.0.0]network 192.168.4.254 0.0.0.0
3.宣告用户网段
[r1]bgp 100
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 2.2.2.2 as-number 100
[r1-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r1-bgp]peer 10.10.10.2 as-number 200
[r1-bgp]peer 10.10.10.6 as-number 200
[r1-bgp]peer 10.10.10.2 allow-as-loop 5
[r1-bgp]peer 10.10.10.2 allow-as-loop 6
[r2]bgp 100
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 1.1.1.1 as-number 100
[r2-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[r2-bgp]peer 10.10.10.10 as-number 200
[r2-bgp]peer 10.10.10.14 as-number 200
[r2-bgp]peer 10.10.10.10 allow-as-loop 5
[r2-bgp]peer 10.10.10.14 allow-as-loop 6
[r5]bgp 200
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 10.10.10.1 as-number 100
[r5-bgp]peer 10.10.10.9 as-number 100
[r5-bgp]peer 6.6.6.6 as-number 200
[r5-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[r5-bgp]peer 7.7.7.7 as-number 200
[r5-bgp]peer 7.7.7.7 connect-interface LoopBack 0
[r5-bgp]peer 8.8.8.8 as-number 200
[r5-bgp]peer 8.8.8.8 connect-interface LoopBack 0
[r5-bgp]peer 7.7.7.7 next-hop-local
[r6]bgp 200
[r6-bgp]router-id 6.6.6.6
[r6-bgp]peer 10.10.10.5 as-number 100
[r6-bgp]peer 10.10.10.13 as-number 100
[r6-bgp]peer 5.5.5.5 as-number 200
[r6-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r6-bgp]peer 7.7.7.7 as-number 200
[r6-bgp]peer 7.7.7.7 connect-interface LoopBack 0
[r6-bgp]peer 8.8.8.8 as-number 200
[r6-bgp]peer 8.8.8.8 connect-interface LoopBack 0
[r6-bgp]peer 7.7.7.7 next-hop-local
[r6-bgp]peer 8.8.8.8 next-hop-local
[r7]bgp 200
[r7-bgp]router-id 7.7.7.7
[r7-bgp]peer 5.5.5.5 as-number 200
[r7-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r7-bgp]peer 6.6.6.6 as-number 200
[r7-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[r7-bgp]peer 8.8.8.8 as-number 200
[r7-bgp]peer 8.8.8.8 connect-interface LoopBack 0
[r8]bgp 200
[r8-bgp]router-id 8.8.8.8
[r8]bgp 200
[r8-bgp]router-id 8.8.8.8
[r8-bgp]peer 5.5.5.5 as-number 200
[r8-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r8-bgp]peer 6.6.6.6 as-number 200
[r8-bgp]peer 6.6.6.6 connect-interface LoopBack 0
[r8-bgp]peer 7.7.7.7 as-number 200
[r8-bgp]peer 7.7.7.7 connect-interface LoopBack 0
[r8-bgp]peer 10.10.10.38 as-number 100
[r8-bgp]peer 5.5.5.5 next-hop-local
[r8-bgp]peer 6.6.6.6 next-hop-local
[r8-bgp]peer 7.7.7.7 next-hop-local
[r9]bgp 100
[r9-bgp]router-id 9.9.9.9
[r9-bgp]peer 10.10.10.37 as-number 200
[r9-bgp]peer 10.10.10.37 allow-as-loop
[r10]bgp 300
[r10-bgp]router-id 1.1.1.1
[r10-bgp]peer 9.9.9.9 as-number 300
[r10-bgp]peer 9.9.9.9 connect-interface LoopBack 0
[r10-bgp]network 192.168.3.0
[r10-bgp]network 192.168.4.0
[r10-bgp]peer 9.9.9.9 next-hop-local
[r10-bgp]network 1.1.1.1 0.0.0.0
实验结果