🔹类型:外部网关协议 EGP
🔹全称:Border Gateway Protocol
🔹文件:BGP指南-IP单播路由.pdf
🔹视频:BGP基础 - 基本原理
🔹链接:BGP配置
简介
BGP用于在不同的自治系统(AS)之间交换路由信息。当两个AS需要交换路由信息时,每个AS都必须指定一个运行BGP的节点,来代表AS与其他的AS交换路由信息。
BGP属于外部网关路由协议,可以实现自治系统间无环路的域间路由。BGP是沟通Internet广域网的主用路由协议,例如不同省份、不同国家之间的路由大多要依靠BGP协议。BGP可分为 IBGP 和 EBGP。BGP的邻居关系(或称通信对端/对等实体)是通过人工配置实现的,对等实体之间通过TCP会话交互数据。BGP路由器会周期地发送19字节的保持存活keep-alive消息来维护连接。在路由协议中,只有BGP使用TCP作为传输层协议。
IBGP 和 EBGP
- IBGP:同一个自治系统(AS)中的两个或多个对等实体之间运行的BGP被称为 IBGP(Internal/Interior BGP)
- EBGP:归属不同的AS的对等实体之间运行的BGP称为 EBGP (External BGP),用于不同AS间路由信息交换
交换机 BGP 配置
EBGP 拓扑


**
配置 Router A-----------------------------------------------------------------------------------------Switch# configure terminal 进入配置模式Switch(config)# interface eth-0-13 进入接口模式Switch(config-if)# no shutdown 启用端口Switch(config-if)# no switchport 将该端口转换为三层interfaceSwitch(config-if)# ip address 1.1.1.1/24 配置IP 地址为1.1.1.1/24Switch(config-if)# exit 退出接口模式并且进入配置模式Switch(config)# interface eth-0-1 进入接口模式Switch(config-if)# no shutdown 启用端口Switch(config-if)# no switchport 将该端口转换为三层interfaceSwitch(config-if)# ip address 2.2.2.1/24 配置IP 地址为2.2.2.1/24Switch(config-if)# exit 退出接口模式并且进入配置模式Switch(config)# ip route 3.3.3.0/24 2.2.2.2 增加一条静态路由Switch(config)# router bgp 100 创建BGP 100 并进入路由模式Switch(config-router)# bgp router-id 10.10.10.10 配置BGP router-idSwitch(config-router)# neighbor 1.1.1.2 remote-as 200 配置EBGP 邻居号200Switch(config)# neighbor 1.1.1.2 ebgp-multihop 配置邻居为ebgp-multihopSwitch(config-router)# network 4.0.0.0/8 宣告网络号Switch(config-router)# redistribute static 重分布静态路由到BGPSwitch(config-router)# redistribute connected 重分布直连路由到BGPSwitch(config-router)# exit 退出路由模式并且进入配置模式配置 Router B---------------------------------------------------------------------------------------Switch# configure terminal 进入配置模式Switch(config)# interface eth-0-13 进入接口模式Switch(config-if)# no shutdown 启用端口Switch(config-if)# no switchport 将该端口转换为三层interfaceSwitch(config-if)# ip address 1.1.1.2/24 配置IP 地址为1.1.1.2/24Switch(config-if)# exit 退出接口模式并且进入配置模式Switch(config)# router bgp 200 创建BGP 200 并进入路由模式Switch(config-router)# bgp router-id 11.11.11.11 配置BGP router-idSwitch(config-router)# neighbor 1.1.1.1 remote-as 100 配置EBGP 邻居号100Switch(config)# neighbor 1.1.1.1 ebgp-multihop 配置邻居为ebgp-multihopSwitch(config-router)# redistribute connected 重分布直连路由到BGPSwitch(config-router)# exit 退出路由模式并且进入配置模式试验结果SwitchA# show ip bgp neighbors-----------------------------------------------------------------------BGP neighbor is 1.1.1.2, remote AS 200, local AS 100, external linkBGP version 4, remote router ID 0.0.0.0BGP state = ActiveLast read 00:26:00, hold time is 180, keepalive interval is 60 secondsReceived 0 messages, 0 notifications, 0 in queueSent 0 messages, 0 notifications, 0 in queueRoute refresh request: received 0, sent 0Minimum time between advertisement runs is 30 secondsFor address family: IPv4 UnicastBGP table version 1, neighbor version 0Index 1, Offset 0, Mask 0x20 accepted prefixes0 announced prefixesConnections established 0; dropped 0External BGP neighbor may be up to 255 hops away.********Next connect timer due in 87 seconds********SwitchB# show ip bgp neighbors----------------------------------------------------------------------BGP neighbor is 1.1.1.1, remote AS 100, local AS 200, external linkBGP version 4, remote router ID 0.0.0.0BGP state = ActiveLast read 00:21:39, hold time is 180, keepalive interval is 60 secondsReceived 0 messages, 0 notifications, 0 in queueSent 0 messages, 0 notifications, 0 in queueRoute refresh request: received 0, sent 0Minimum time between advertisement runs is 30 secondsFor address family: IPv4 UnicastBGP table version 1, neighbor version 0Index 1, Offset 0, Mask 0x20 accepted prefixes0 announced prefixesConnections established 0; dropped 0External BGP neighbor may be up to 255 hops away.Next connect timer due in 97 seconds
IBGP 拓扑


配置 Router A-----------------------------------------------------------------------------------------Switch #configure terminal 进入配置模式Switch (config)# interface eth-0-13 进入接口模式Switch (config-if)# no shutdown 启用端口Switch (config-if)# no switchport 将该端口转换为三层interfaceSwitch (config-if)# ip address 1.1.1.1/24 配置IP 地址为1.1.1.1/24Switch (config-if)# exit 退出接口模式并且进入配置模式Switch (config)# interface loopback 0 进入接口模式Switch (config-if)# ip address 10.10.10.10/32 配置IP 地址为10.10.10.10/32Switch (config-if)# exit 退出接口模式并且进入配置模式Switch (config)# ip route 11.11.11.11/32 1.1.1.2 增加一条静态路由Switch (config)# interface eth-0-1 进入接口模式Switch (config-if)# no shutdown 启用端Switch (config-if)# no switchport 将该端口转换为三层interfaceSwitch (config-if)# ip address 2.2.2.1/24 配置IP 地址为2.2.2.1/24Switch (config-if)# exit 退出接口模式并且进入配置模式Switch (config)# ip route 3.3.3.0/24 2.2.2.2 增加一条静态路由Switch (config)# router bgp 100 创建BGP 100 并进入路由模式Switch (config-router)# bgp router-id 10.10.10.10 配置BGP router-idSwitch (config-router)# neighbor 11.11.11.11 remote-as 100 配置IBGP 邻居AS 号100Switch (config-router)# neighbor 11.11.11.11 update-source loopback 0 配置loopback0 为更新源端口Switch (config-router)# network 4.0.0.0/8 宣告网络号Switch (config-router)# redistribute static 重分布静态路由到BGPSwitch (config-router)# redistribute connected 重分布直连路由到BGPSwitch (config-router)# exit 退出路由模式并且进入配置模式配置 Router B---------------------------------------------------------------------------------------Switch #configure terminal 进入配置模式Switch (config)# interface eth-0-13 进入接口模式Switch (config-if)# no shutdown 启用端口Switch (config-if)# no switchport 将该端口转换为三层interfaceSwitch (config-if)# ip address 1.1.1.2/24 配置IP 地址为1.1.1.2/24Switch (config-if)# exit 退出接口模式并且进入配置模式Switch (config)# interface loopback 0 进入接口模式Switch (config-if)# ip address 11.11.11.11/32 配置IP 地址为11.11.11.11/32Switch (config-if)# exit 退出接口模式并且进入配置模式Switch (config)# ip route 10.10.10.10/32 1.1.1.1 增加一条静态路由Switch (config)# router bgp 100 创建BGP 100 并进入路由模式Switch (config-router)# bgp router-id 11.11.11.11 配置BGP router-idSwitch (config-router)# neighbor 10.10.10.10 remote-as 100 配置IBGP 邻居AS 号100Switch (config-router)# neighbor 10.10.10.10 update-source loopback 0 配置loopback0 为更新源端口Switch (config-router)# redistribute connected 重分布直连路由到BGPSwitch (config-router)# exit 退出路由模式并且进入配置模式试验结果SwitchA# show ip bgp neighbors-----------------------------------------------------------------------BGP neighbor is 11.11.11.11, remote AS 100, local AS 100, internal linkBGP version 4, remote router ID 0.0.0.0BGP state = ActiveLast read 00:02:32, hold time is 180, keepalive interval is 60 secondsReceived 0 messages, 0 notifications, 0 in queueSent 0 messages, 0 notifications, 0 in queueRoute refresh request: received 0, sent 0Minimum time between advertisement runs is 5 secondsUpdate source is loopback0For address family: IPv4 UnicastBGP table version 1, neighbor version 0Index 1, Offset 0, Mask 0x20 accepted prefixes0 announced prefixesConnections established 0; dropped 0Next connect timer due in 62 secondsSwitchB# show ip bgp neighbors----------------------------------------------------------------------BGP neighbor is 10.10.10.10, remote AS 100, local AS 100, internal linkBGP version 4, remote router ID 0.0.0.0BGP state = ActiveLast read 00:01:58, hold time is 180, keepalive interval is 60 secondsReceived 0 messages, 0 notifications, 0 in queueSent 0 messages, 0 notifications, 0 in queueRoute refresh request: received 0, sent 0Minimum time between advertisement runs is 5 secondsUpdate source is loopback0For address family: IPv4 UnicastBGP table version 1, neighbor version 0Index 1, Offset 0, Mask 0x20 accepted prefixes0 announced prefixesConnections established 0; dropped 0Next connect timer due in 17 seconds

