要求:
用BGP连接AS 100,200,300
配置:
r1:
配置IP:
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.0.0.1 24
[r1]interface LoopBack 0
[r1-LoopBack0]ip address 1.1.1.1 32
[r1]interface LoopBack 1
[r1-LoopBack1]ip address 21.0.0.1 24
BGP配置:
[r1]bgp 100–启动BGP协议
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.0.0.2 as-number 200
[r1-bgp]network 1.1.1.1 32
[r1-bgp]network 21.0.0.0 24
r2
配置IP:
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip address 12.0.0.2 24
[r2]interface GigabitEthernet 0/0/1
[r2-GigabitEthernet0/0/1]ip address 23.0.0.2 24
[r2]interface LoopBack 0
[r2-LoopBack0]ip address 2.2.2.2 32
[r2]interface LoopBack 1
[r2-LoopBack1]ip address 14.0.0.1 24
OSPF配置:
[r2]ospf 1
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 23.0.0.2 0.0.0.0
BGP配置:
[r2]bgp 200
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.0.0.1 as-number 100
[r2-bgp]peer 3.3.3.3 as-number 200
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r2-bgp]peer 3.3.3.3 next-hop-local
[r2-bgp]peer 4.4.4.4 as-number 200
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r2-bgp]peer 4.4.4.4 next-hop-local
[r2-bgp]import-route ospf 1
[r2-bgp]network 14.0.0.0 24
[r2-bgp]network 12.0.0.0 24
r3
配置IP:
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ip address 23.0.0.3 24
[r3]interface GigabitEthernet 0/0/1
[r3-GigabitEthernet0/0/1]ip address 34.0.0.3 24
[r3]interface LoopBack 0
[r3-LoopBack0]ip address 3.3.3.3 32
OSPF配置:
[r3]ospf 1
[r3-ospf-1]area 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 23.0.0.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 34.0.0.3 0.0.0.0
BGP配置:
[r3]bgp 200
[r3-bgp]peer 2.2.2.2 as-number 200
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 as-number 200
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r3-bgp]network 33.0.0.0 24----宣告新增环回接口1
r4
配置IP:
[r4]interface GigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ip address 34.0.0.4 24
[r4]interface GigabitEthernet 0/0/1
[r4-GigabitEthernet0/0/1]ip address 45.0.0.4 24
[r4]interface LoopBack 0
[r4-LoopBack0]ip address 4.4.4.4 32
OSPF配置:
[r4]ospf 1
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 34.0.0.4 0.0.0.0
BGP配置:
[r4]bgp 200
[r4-bgp]peer 2.2.2.2 as-number 200
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r4-bgp]peer 2.2.2.2 next-hop-local
[r4-bgp]peer 3.3.3.3 as-number 200
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r4-bgp]peer 3.3.3.3 next-hop-local
[r4]bgp 200
[r4-bgp]peer 5.5.5.5 as-number 300
[r4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2
[r4-bgp]network 44.0.0.0 24
[r4-bgp]network 45.0.0.0 24
[r4-bgp]network 5.5.5.5 32
r5
配置IP:
[r5]interface GigabitEthernet 0/0/0
[r5-GigabitEthernet0/0/0]ip address 45.0.0.5 24
[r5]interface LoopBack 0
[r5-LoopBack0]ip address 5.5.5.5 32
[r5]interface LoopBack 1
[r5-LoopBack1]ip address 10.0.0.1 24
[r5]interface LoopBack 2
[r5-LoopBack2]ip address 11.0.0.1 24
BGP配置:
[r5]bgp 300
[r5-bgp]peer 4.4.4.4 as-number 200
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2
[r5-bgp]network 10.0.0.0 24
测试: