基于直连口建BGP <Huawei>system-view [ra]sysname r1 接口配置 [r1]interfacegigabitethernet 0/0/0 [r1-GigabitEthernet0/0/0]ipaddress 10.10.12.1 24 [r1-GigabitEthernet0/0/0]interfaceloopback 10 [r1-LoopBack10]ipaddress 10.1.1.1 32 [r1-LoopBack10]interfaceloopback 0 [r1-LoopBack0]ipaddress 10.10.10.1 32 [r1-LoopBack0]interfaceloopback 1 [r1-LoopBack1]ipaddress 10.10.1.1 24 [r1-LoopBack1]ospfnetwork-type broadcast [r1-LoopBack1]quit BGP基于TCP协议,所以要通BGP先通IGP,配置OSPF承载IBGP [r1]ospf 1router-id 10.10.10.1 [r1-ospf-1-area-0.0.0.0]authentication-modemd5 1 cipher admin1234 [r1-ospf-1-area-0.0.0.0]network10.10.12.0 0.0.0.255 [r1-ospf-1-area-0.0.0.0]network10.10.10.1 0.0.0.0 [r1-ospf-1-area-0.0.0.0]network10.10.1.0 0.0.0.255 [r1-ospf-1-area-0.0.0.0]network10.1.1.1 0.0.0.0 [r1-ospf-1-area-0.0.0.0]quit [r1-ospf-1]quit [r1]display ospfinterface //检验OSPF接口 配置IBGP [r1]bgp 200 //创建BGP AS编号200 [r1-bgp]peer10.10.12.2 as-number 200 //指定邻居地址 AS编号为本BGP编号 R2 <Huawei>system-view [Huawei]sysname r2 配置接口 [r2]interfaceloopback 0 [r2-LoopBack0]ipaddress 10.10.10.2 32 [r2-LoopBack0]quit [r2]interfacegigabitethernet 0/0/1 [r2-GigabitEthernet0/0/1]ipaddress 10.10.12.2 24 [r2-GigabitEthernet0/0/1]interfacegigabitethernet 0/0/0 [r2-GigabitEthernet0/0/0]ipaddress 10.10.23.2 24 [r2-GigabitEthernet0/0/0]quit 配置OSPF [r2]ospf 1router-id 10.10.10.2 [r2-ospf-1]area 0 [r2-ospf-1-area-0.0.0.0]authentication-modemd5 1 cipher admin1234 [r2-ospf-1-area-0.0.0.0]network10.10.12.0 0.0.0.255 [r2-ospf-1-area-0.0.0.0]quit [r2-ospf-1]quit [r2]display iprouting-table protocol ospf 配置IBGP及EBGP [r2]bgp 200 [r2-bgp]peer10.10.12.1 as-number 200 //IBGP [r2-bgp]peer10.10.23.3 as-number 100 //EBGP BGP宣告参与网络的方法一 [r2-bgp]network10.1.1.1 32 [r2-bgp]network10.10.1.0 24 [r2-bgp]network10.10.10.1 32 [r2-bgp]network10.10.0.0 16 //测试 [r2-bgp]network10.10.10.2 32 [r2-bgp]quit [r2]iproute-static 10.10.0.0 16 null 0 //测试 <Huawei>system-view [Huawei]sysname r3 配置接口 [r3]interfaceloopback 0 [r3-LoopBack0]ipaddress 10.10.10.3 32 [r3-LoopBack0]quit [r3]interfacegigabitethernet 0/0/1 [r3-GigabitEthernet0/0/1]ipaddress 10.10.23.3 24 [r3-GigabitEthernet0/0/1]quit 配置EBGP [r3]bgp 100 [r3-bgp]peer10.10.23.2 as-number 200 [r3-bgp]network10.10.10.3 32 [r3-bgp]network10.10.23.3 24 [r3-bgp]quit [r3]display bgprouting-table R2使用路由引入方式 假设BGP的路由有几千上万条之多,一条一个的network宣告进去将会非常不方便,使用路由引入方法。 [r2]bgp 200 [r2-bgp]import-routeospf 1 //在BGP中引入所有OSPF路由 [r2-bgp]network10.10.23.0 24 [r3]display bgp routing-table BGP Local router ID is 10.10.23.3 Status codes: * - valid, > -best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e- EGP, ? - incomplete Total Number of Routes: 7 Network NextHop MED LocPrf PrefVal Path/Ogn *> 10.1.1.1/32 10.10.23.2 1 0 200? *> 10.10.1.0/24 10.10.23.2 1 0 200? *> 10.10.10.1/32 10.10.23.2 1 0 200? *> 10.10.10.2/32 10.10.23.2 0 0 200i *> 10.10.10.3/32 0.0.0.0 0 0 i *> 10.10.12.0/24 10.10.23.2 0 0 200? *> 10.10.23.0/24 0.0.0.0 0 0 i 测试EBGP R1与R3之间有通信 [r3]ping -a 10.10.10.3 10.10.10.1 PING 10.10.10.1: 56 data bytes, press CTRL_C to break Reply from 10.10.10.1:bytes=56 Sequence=1 ttl=254 time=50 ms Reply from 10.10.10.1:bytes=56 Sequence=2 ttl=254 time=40 ms Reply from 10.10.10.1:bytes=56 Sequence=3 ttl=254 time=40 ms Reply from 10.10.10.1:bytes=56 Sequence=4 ttl=254 time=20 ms Reply from 10.10.10.1:bytes=56 Sequence=5 ttl=254 time=20 ms --- 10.10.10.1 ping statistics--- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max =20/34/50 ms
|