它是用于自治系统(AS)间通信的路由协议,自治系统内的路由器互为IBGP邻居,处于边界的路由器与相邻的自治系统边界路由器互为EBGP邻居。自治系统内通常采用OSPF动态路由协议。
open报文:发hello建立邻居关系
Update报文:更新路由
Notification报文:报错
Route-refresh:刷新路由表
keepalive:维持邻居关系
● 从IBGP对等体获得的BGP路由,BGP设备只传递给它的EBGP对等体
● 从EBGP对等体获得的BGP路由,BGP设备传递给它所有EBGP和IBGP对
等体(对等体是IBGP只能传递一-跳, 对等体是EBGP则不限制)
● 当存在多条到达同一目的地址的有效路由时,BGP设备只将最优路由发布给对等体,路由更新时,BGP设备只发送更新的BGP路由
● 所有对等体发送的路由,BGP设备都会接收
● 所有EBGP对等体在传递过程中下一-跳改变
● 所有IBGP对等体在传递过程中下一-跳不变
● 默认EBGP传递时TTL值为1
● 默认IBGP传递时TTL值为255
原因是环回口稳定,只要路由器启动着,环回口就不down, 而物理链路可能会受线路或者是接口等因素的影响导致邻居关系有问题,因而–般BGP建立邻居都是用环回口来建。
(1) 若去往目的网络的路由下一-跳不可达,则可以忽略此路由
(2) Preferred-Value优先级以数值高的路由优先
(3) Local-Preference优先级以数值高的路由优先
(4) 聚合路由优先级高于非聚合路由
(5) 本地手动聚合路由的优先级高于本地自动聚合的路由
(6) 本地通过Network命令引入的路由的优先级高于本地通过Import-route命令引入的路由
(7) AS路径长度最短(最少个数)的路径优先级高
(8) 比较0rigin属性,IGP优先级高于EGP, EGP优先级高于Incomplete
(9) 选择MED优先级较小的路由
(10) EBGP路由优先级高于IBGP路由
(11) BGP优先选择到BGP下- -跳的IGP度量低的路径
当以上全部相同,则为等价路由,可以负载分担(注: AS-PATH必须一致),当负载分担时,以下3条原则无效
(12) 比较Cluster-List长度, 短者优先
(13) 比较Originator_ ID(如果没有Originator_ ID,则用Router ID比较),选择数值较小的路径
(14) 比较对等体的IP地址,选择IP地址数值最小的路径
#
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 13.1.1.1 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
bgp 100
peer 2.2.2.2 as-number 200
peer 2.2.2.2 ebgp-max-hop 255
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 as-number 200
peer 3.3.3.3 ebgp-max-hop 255
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 1.1.1.1 255.255.255.255
network 2.2.2.2 255.255.255.255
network 3.3.3.3 255.255.255.255
network 12.1.1.0 255.255.255.0
network 13.1.1.0 255.255.255.0
peer 2.2.2.2 enable
peer 3.3.3.3 enable
#
ip route-static 2.2.2.2 255.255.255.255 12.1.1.2
ip route-static 3.3.3.3 255.255.255.255 13.1.1.2
#
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 23.1.1.1 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
bgp 200
peer 1.1.1.1 as-number 100
peer 1.1.1.1 ebgp-max-hop 255
peer 1.1.1.1 connect-interface LoopBack0
peer 3.3.3.3 as-number 200
peer 3.3.3.3 connect-interface LoopBack0
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 1.1.1.1 255.255.255.255
network 2.2.2.2 255.255.255.255
network 3.3.3.3 255.255.255.255
network 4.4.4.4 255.255.255.255
network 12.1.1.0 255.255.255.0
network 23.1.1.0 255.255.255.0
peer 1.1.1.1 enable
peer 3.3.3.3 enable
peer 3.3.3.3 next-hop-local
peer 4.4.4.4 enable
peer 4.4.4.4 next-hop-local
#
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 23.1.1.0 0.0.0.255
#
ip route-static 1.1.1.1 255.255.255.255 12.1.1.1
#
acl number 2000
rule 5 permit source 1.1.1.1 0
#
interface GigabitEthernet0/0/0
ip address 13.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 24.1.1.1 255.255.255.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
bgp 200
peer 1.1.1.1 as-number 100
peer 1.1.1.1 ebgp-max-hop 255
peer 1.1.1.1 connect-interface LoopBack0
peer 2.2.2.2 as-number 200
peer 2.2.2.2 connect-interface LoopBack0
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 1.1.1.1 255.255.255.255
network 2.2.2.2 255.255.255.255
network 3.3.3.3 255.255.255.255
network 4.4.4.4 255.255.255.255
network 13.1.1.0 255.255.255.0
network 16.0.0.0 240.0.0.0
network 24.1.1.0 255.255.255.0
peer 1.1.1.1 enable
peer 2.2.2.2 enable
peer 2.2.2.2 next-hop-local
peer 4.4.4.4 enable
peer 4.4.4.4 route-policy local export
peer 4.4.4.4 next-hop-local
#
ospf 1
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 24.1.1.0 0.0.0.255
#
route-policy local permit node 10
if-match acl 2000
apply local-preference 200
#
route-policy local permit node 20
#
ip route-static 1.1.1.1 255.255.255.255 13.1.1.1
#
#
interface GigabitEthernet0/0/0
ip address 23.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 24.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 34.1.1.1 255.255.255.0
#
interface GigabitEthernet1/0/0
ip address 35.1.1.1 255.255.255.0
#
interface NULL0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
bgp 200
peer 2.2.2.2 as-number 200
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 as-number 200
peer 5.5.5.5 as-number 300
peer 5.5.5.5 ebgp-max-hop 255
peer 5.5.5.5 connect-interface LoopBack0
peer 6.6.6.6 as-number 300
peer 6.6.6.6 ebgp-max-hop 255
peer 6.6.6.6 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 2.2.2.2 enable
peer 2.2.2.2 next-hop-local
peer 3.3.3.3 enable
peer 5.5.5.5 enable
peer 6.6.6.6 enable
#
ospf 1
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 23.1.1.0 0.0.0.255
network 24.1.1.0 0.0.0.255
#
ip route-static 5.5.5.5 255.255.255.255 34.1.1.2
ip route-static 6.6.6.6 255.255.255.255 35.1.1.2
#
acl number 2000
rule 5 permit source 1.1.1.1 0
#
interface GigabitEthernet0/0/0
ip address 34.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 45.1.1.1 255.255.255.0
#
interface LoopBack0
ip address 5.5.5.5 255.255.255.255
#
bgp 300
peer 4.4.4.4 as-number 200
peer 4.4.4.4 ebgp-max-hop 255
peer 4.4.4.4 connect-interface LoopBack0
peer 6.6.6.6 as-number 300
peer 6.6.6.6 connect-interface LoopBack0
peer 7.7.7.7 as-number 300
peer 7.7.7.7 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 0.0.0.0
network 4.4.4.4 255.255.255.255
network 5.5.5.5 255.255.255.255
network 6.6.6.6 255.255.255.255
network 7.7.7.7 255.255.255.255
network 34.1.1.0 255.255.255.0
network 45.1.1.0 255.255.255.0
peer 4.4.4.4 enable
peer 6.6.6.6 enable
peer 6.6.6.6 next-hop-local
peer 7.7.7.7 enable
peer 7.7.7.7 route-policy as export
peer 7.7.7.7 next-hop-local
#
ospf 1
area 0.0.0.0
network 5.5.5.5 0.0.0.0
network 45.1.1.0 0.0.0.255
#
route-policy as permit node 10
if-match acl 2000
apply as-path 111 222 333 additive
#
route-policy as permit node 20
#
ip route-static 4.4.4.4 255.255.255.255 34.1.1.1
#
interface GigabitEthernet0/0/0
ip address 46.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 35.1.1.2 255.255.255.0
#
interface LoopBack0
ip address 6.6.6.6 255.255.255.255
#
bgp 300
peer 4.4.4.4 as-number 200
peer 4.4.4.4 ebgp-max-hop 255
peer 4.4.4.4 connect-interface LoopBack0
peer 5.5.5.5 as-number 300
peer 5.5.5.5 connect-interface LoopBack0
peer 7.7.7.7 as-number 300
peer 7.7.7.7 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 4.4.4.4 255.255.255.255
network 5.5.5.5 255.255.255.255
network 6.6.6.6 255.255.255.255
network 7.7.7.7 255.255.255.255
network 35.1.1.0 255.255.255.0
network 46.1.1.0 255.255.255.0
peer 4.4.4.4 enable
peer 5.5.5.5 enable
peer 5.5.5.5 next-hop-local
peer 7.7.7.7 enable
peer 7.7.7.7 next-hop-local
#
ospf 1
area 0.0.0.0
network 6.6.6.6 0.0.0.0
network 46.1.1.0 0.0.0.255
#
ip route-static 4.4.4.4 255.255.255.255 35.1.1.1
#
interface GigabitEthernet0/0/0
ip address 45.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 46.1.1.2 255.255.255.0
#
interface LoopBack0
ip address 7.7.7.7 255.255.255.255
#
bgp 300
peer 5.5.5.5 as-number 300
peer 5.5.5.5 connect-interface LoopBack0
peer 6.6.6.6 as-number 300
peer 6.6.6.6 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 5.5.5.5 enable
peer 6.6.6.6 enable
#
ospf 1
area 0.0.0.0
network 7.7.7.7 0.0.0.0
network 45.1.1.0 0.0.0.255
network 46.1.1.0 0.0.0.255