边界网关协议BGP是一种实现自治系统AS之间的路由可达,并选择最佳路由的距离矢量路由协议。BGP在不同自治系统之间进行路由转发,分为EBGP(外部边界网关协议)和IBGP(内部边界网关协议)两种情况。
[A]in g0/0/2
[A-GigabitEthernet0/0/2]ip ad 172.16.60.1 24
[A-GigabitEthernet0/0/2]in g0/0/1
[A-GigabitEthernet0/0/1]ip ad 59.74.112.2 24
[B]in g0/0/0
[B-GigabitEthernet0/0/0]ip ad 59.74.112.1 24
[B-GigabitEthernet0/0/0]in g0/0/1
[B-GigabitEthernet0/0/1]ip ad 172.16.30.1 24
[B-GigabitEthernet0/0/1]in g0/0/2
[B-GigabitEthernet0/0/2]ip ad 172.16.10.1 24
#配置IBGP连接
[B]bgp 65009
[B-bgp]router-id 2.2.2.2
[B-bgp]peer 172.16.30.2 as-number 65009
[B-bgp]peer 172.16.10.2 as-number 65009
[C]in g0/0/1
[C-GigabitEthernet0/0/1]ip ad 172.16.30.2 24
[C-GigabitEthernet0/0/1]in g0/0/2
[C-GigabitEthernet0/0/2]ip ad 172.16.20.1 24
#配置IBGP连接
[C]bgp 65009
[C-bgp]router-id 3.3.3.3
[C-bgp]peer 172.16.30.1 as-number 65009
[C-bgp]peer 172.16.20.2 as-number 65009
[D]in g0/0/1
[D-GigabitEthernet0/0/1]ip ad 172.16.10.2 24
[D-GigabitEthernet0/0/1]in g0/0/2
[D-GigabitEthernet0/0/2]ip ad 172.16.20.2 24
#配置IBGP连接
[D]bgp 65009
[D-bgp]router-id 4.4.4.4
[D-bgp]peer 172.16.10.1 as-number 65009
[D-bgp]peer 172.16.20.1 as-number 65009
#配置EBGP连接,配置路由器A和B:
[A]bgp 65008
[A-bgp]router-id 1.1.1.1
[A-bgp]peer 59.74.112.1 as-number 65009
[B]bgp 65009
[B-bgp]peer 59.74.112.2 as-number 65008
查看BGP对等体连接状态:
配置路由器A,发布路由172.16.60.0/24:
[A]bgp 65008
[A-bgp]ipv4-family unicast
[A-bgp-af-ipv4]network 172.16.60.0 255.255.255.0
[A-bgp-af-ipv4]q
查看A、B、C、D路由表信息 :
路由器C虽然学习到了AS65008中的172.16.60.0的路由,但因为下一跳59.74.112.2不可达,所以不是有效路由。
配置BGP引入直连路由,配置路由器B:
[B]bgp 65009
[B-bgp]ipv4-family unicast
[B-bgp-af-ipv4]import-route direct
如下图可看出到172.16.60.0的路由为有效路由:
成功Ping通: