组网需求
如下图所示,需要在所有AR间运行BGP协议,AR1、AR2之间建立EBGP连接,AR2、AR3和AR4之间建立IBGP全连接。
配置思路
采用如下的思路配置BGP的基本功能:
- 在AR2、AR3和AR4间配置IBGP连接。
- 在AR1和AR2之间配置EBGP连接。
操作步骤
配置IP
AR1
<Huawei> [Huawei]sys AR1 [AR1]int g0/0/0 [AR1-GigabitEthernet0/0/0]ip add 12.12.12.1 24 [AR1-GigabitEthernet0/0/0]q [AR1]int lo1 [AR1-LoopBack1]ip add 1.1.1.1 8 [AR1-LoopBack1]q
AR2
<Huawei> [Huawei]sys AR2 [AR2]int g0/0/0 [AR2-GigabitEthernet0/0/0]ip add 12.12.12.1 24 [AR2-GigabitEthernet0/0/0]q [AR2]int g0/0/1 [AR2-GigabitEthernet0/0/1]ip add 24.24.24.2 24 [AR2-GigabitEthernet0/0/1]q [AR2]int g0/0/2 [AR2-GigabitEthernet0/0/2]ip add 23.23.23.2 24 [AR2-GigabitEthernet0/0/2]q
AR3
<Huawei> [Huawei]sys AR3 [AR3]int g0/0/0 [AR3-GigabitEthernet0/0/0]ip add 34.34.34.3 24 [AR3-GigabitEthernet0/0/0]q [AR3]int g0/0/1 [AR3-GigabitEthernet0/0/1]ip add 23.23.23.3 24 [AR3-GigabitEthernet0/0/1]q
AR4
<Huawei> [Huawei]sys AR4 [AR4]int g0/0/0 [AR4-GigabitEthernet0/0/0]ip add 34.34.34.4 24 [AR4-GigabitEthernet0/0/0]q [AR4]int g0/0/1 [AR4-GigabitEthernet0/0/1]ip add 24.24.24.4 24 [AR4-GigabitEthernet0/0/1]q
配置IBGP
AR2
[AR2]bgp 65009 [AR2-bgp]router-id 2.2.2.2 [AR2-bgp]peer 23.23.23.2 as-number 65009 [AR2-bgp]peer 24.24.24.4 as-number 65009 [AR2-bgp]q
AR3
[AR3]bgp 65009 [AR3-bgp]router-id 3.3.3.3 [AR3-bgp]peer 23.23.23.2 as-number 65009 [AR3-bgp]peer 34.34.34.4 as-number 65009 [AR3-bgp]q
AR4
[AR4]bgp 65009 [AR4-bgp]router-id 4.4.4.4 [AR4-bgp]peer 34.34.34.3 as-number 65009 [AR4-bgp]peer 24.24.24.2 as-number 65009 [AR4-bgp]q
配置EBGP
AR1
[AR1]bgp 65008 [AR1-bgp]router-id 1.1.1.1 [AR1-bgp]peer 12.12.12.2 as-number 65009 [AR1-bgp]q
AR2
[AR2]bgp 65009 [AR2-bgp]peer 12.12.12.1 as-number 65008 [AR2-bgp]q
查看AR2对等体的状态
<AR2>display bgp peer BGP local router ID : 2.2.2.2 Local AS number : 65009 Total number of peers : 3 Peers in established state : 3 Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv 12.12.12.1 4 65008 29 33 0 00:26:31 Established 1 23.23.23.3 4 65009 38 43 0 00:36:42 Established 0 24.24.24.4 4 65009 34 39 0 00:32:52 Established 0
发布AR1 LoopBack1端口
AR1
[AR1]bgp 65008 [AR1-bgp]ipv4-family unicast [AR1-bgp-af-ipv4]network 1.0.0.0 255.0.0.0 [AR1-bgp-af-ipv4]q
查看路由表
AR1
[AR1-bgp]display bgp routing-table BGP Local router ID is 12.12.12.1 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 1 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.0.0.0 0.0.0.0 0 0 i
AR2
[AR2-bgp]display bgp routing-table BGP Local router ID is 2.2.2.2 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 1 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.0.0.0 12.12.12.1 0 0 65008i
AR4
<AR4>display bgp routing-table BGP Local router ID is 4.4.4.4 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 1 Network NextHop MED LocPrf PrefVal Path/Ogn i 1.0.0.0 12.12.12.1 0 100 0 65008i
从路由表可以看出,AR4虽然学到了AS65008中的1.0.0.0的路由,但因为下一跳12.12.12.1不可达,所以不是有效路由
bgp引入直连路由
AR2
[AR2]bgp 65009 [AR2-bgp] ipv4-family unicast [AR2-bgp-af-ipv4] import-route direct
查看路由表
AR1
<AR1>display bgp routing-table BGP Local router ID is 12.12.12.1 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 4 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.0.0.0 0.0.0.0 0 0 i 12.12.12.0/24 12.12.12.2 0 0 65009? *> 23.23.23.0/24 12.12.12.2 0 0 65009? *> 24.24.24.0/24 12.12.12.2 0 0 65009?
AR4
<AR4>display bgp routing-table BGP Local router ID is 4.4.4.4 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 4 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 1.0.0.0 12.12.12.1 0 100 0 65008i *>i 12.12.12.0/24 24.24.24.2 0 100 0 ? *>i 23.23.23.0/24 24.24.24.2 0 100 0 ? i 24.24.24.0/24 24.24.24.2 0 100 0 ?
从路由表可以看出,AR4知道下一跳12.12.12.1如何到达
验证
在AR4上ping AR1上的LoopBack1口
<AR4>ping 1.1.1.1 PING 1.1.1.1: 56 data bytes, press CTRL_C to break Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=254 time=30 ms Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=254 time=30 ms Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=254 time=30 ms Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=254 time=40 ms Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=254 time=30 ms --- 1.1.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 30/32/40 ms