BGP实验
接口环回IP配置:
R1:
int g0/0/1
ip add 12.1.1.1 24
int g0/0/2
ip add 10.1.1.1 24
int l0
ip add 1.1.1.1 24
R2:
int g0/0/0
ip add 12.1.1.2 24
int g0/0/1
ip add 23.1.1.1 24
int g0/0/2
ip add 20.1.1.1 24
int l0
ip add 2.2.2.2 24
R3:
int g0/0/0
ip add 23.1.1.2 24
int g0/0/1
ip add 34.1.1.1 24
int g0/0/2
ip add 30.1.1.1 24
int l0
ip add 3.3.3.3 24
R4:
int g0/0/0
ip add 34.1.1.2 24
int g0/0/1
ip add 45.1.1.1 24
int g0/0/2
ip add 54.1.1.1 24
int g4/0/0
ip add 40.1.1.1 24
int l0
ip add 4.4.4.4 24
R5:
int g0/0/0
ip add 45.1.1.2 24
int g0/0/1
ip add 54.1.1.2 24
int g0/0/2
ip add 50.1.1.1 24
int l0
ip add 5.5.5.5 24
AS2内部运行OSPF
R2:
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 20.1.1.1 0.0.0.0
network 23.1.1.1 0.0.0.0
R3:
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 23.1.1.2 0.0.0.0
network 30.1.1.1 0.0.0.0
network 34.1.1.1 0.0.0.0
R4:
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 34.1.1.2 0.0.0.0
network 40.1.1.1 0.0.0.0
R1R2之间运行EBGP
R1:
[r1]bgp 1
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as-number 2
R2:
[r2]bgp 2
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.1.1.1 as-number 1
R2R3之间运行IBGP
R2:
[r2]bgp 2
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
R3:
[r3]bgp 2
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as-number 2
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
R3R4之间同样:
R3:
[r3-bgp]peer 4.4.4.4 as-number 2
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
R4:
[r4]bgp 2
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 3.3.3.3 as-number 2
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
因为R4环回到R5环回是没有路由的,所以写一条静态
R4:
[r4]ip route-static 5.5.5.0 24 45.1.1.2
[r4]ip route-static 5.5.5.0 24 54.1.1.2
R5:
[r5]ip route-static 4.4.4.0 24 45.1.1.1
[r5]ip route-static 4.4.4.0 24 54.1.1.1
有路由才能建邻
R4:
[r4]bgp 2
[r4-bgp]peer 5.5.5.5 as-number 3
[r4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
R5:
[r5]bgp 3
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 4.4.4.4 as-number 2
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
但E之间TTL=1,所以我们去修改
R4:
[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2
R5:
[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2
R1:
[r1]ip route-static 2.2.2.0 24 12.1.1.2
R2:
[r2]ip route-static 1.1.1.0 24 12.1.1.1
现在我们将用户网段从R1宣告出去:
R1:
[r1]bgp 1
[r1-bgp]network 10.1.1.0 24
R2:把路由给3的时候下一跳属性改为自己
[r2-bgp]peer 3.3.3.3 next-hop-local
4还是没有BGP表,在2上与4建邻
R2:
[r2-bgp]peer 4.4.4.4 as-number 2
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
R4:
[r4]bgp 2
[r4-bgp]peer 2.2.2.2 as-number 2
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
R2:
[r2-bgp]peer 4.4.4.4 next-hop-local
这时4上的bgp路由最优了,5也是,现在去宣告5的用户网段
R5:
[r5-bgp]network 50.1.1.0 24
在R4上针对邻居修改下一跳
[r4-bgp]peer 3.3.3.3 next-hop-local
[r4-bgp]peer 2.2.2.2 next-hop-local
目前R1R5用户网段已通,现在去做R2R3R4的用户网段
R2:
[r2-bgp]network 20.1.1.0 24
R3:
[r3-bgp]network 30.1.1.0 24
R4:
[r4-bgp]network 40.1.1.0 24
再去查看R1R2R3R4R5的BGP路由表发现所有用户网段都齐了
用PC1区ping任意PC的IP地址:
实验完成!