华为与思科
BGP
的基本配置命令
思科的配置命令:
下面的拓扑图用的是
c
类的
IP
地址,为了便于理解,我用路由器之间的名字作为
IP
地址的
下面的是
R1
到
R8
的关于
BGP
的配置命令
(R1-R6
为
AS65001
,
R7-R8
为
AS65002
,两个
AS
间运行静态路由
)
注:看上图
R1-R6
之间我不建立全互联,只与它们直连网段的路由器建立邻居关系,然后在
R2
和
R5
上做路由反射器
R1
的配置命令
R1(config)#router bgp 65001 //
启动
BGP
的进程
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#no synchronization //
关闭同步
R1(config-router)#bgp log-neighbor-changes //
用于网管监控邻居状态的改变
R1(config-router)#no auto-summary //
关闭自动汇总
R1(config-router)#network 202.106.1.0 mask 255.255.255.0 //
把
M1
上的主机的
IP
地址通告出去(
M1
和
R1
、
R4
做的
VRRP
过程略)
R1(config-router)#neighbor 2.2.2.2 remote-as 65001 //
指定邻居路由器所在的
AS
R1(config-router)#neighbor 2.2.2.2 update-source loo0 //
指定更新源
R1(config-router)#neighbor 5.5.5.5 remote-as 65001
R1(config-router)#neighbor 5.5.5.5 update-source loo0
R2
的配置命令
R2(config)#router bgp 65001
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#no synchronization
R2(config-router)#no auto-summary
R2(config-router)#bgp log-neighbor-changes
R2(config-router) bgp cluster-id 10 //在一个网络中有两台路由器做反射器[R2和R3与R5和R6做路由反映器]时要指定cluster-id的,而且id号是要一样的
R2(config-router) neighbor 3.3.3.3 route-reflector-client //指定客户端为R3(R2和R3路由的反射器)
R2(config-router)#neighbor 1.1.1.1 remote-as 65001
R2(config-router)#neighbor 1.1.1.1 update-source loo0
R2(config-router)#neighbor 4.4.4.4 remote-as 65001
R2(config-router)#neighbor 4.4.4.4 update-source loo0
R2(config-router)#neighbor 3.3.3.3 remote-as 65001
R2(config-router)#neighbor 3.3.3.3 update-source loo0
R2(config-router)#neighbor 5.5.5.5 remote-as 65001
R2(config-router)#neighbor 5.5.5.5 update-source loo0
R3
的配置命令
R3(config)#router bgp 65001
R3(config-router)#no synchronization
R3(config-router)#no auto-summary
R3(config-router)#bgp log-neighbor-changes
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 2.2.2.2 remote-as 65001
R3(config-router)#neighbor 2.2.2.2 update-source loo0
R3(config-router)#neighbor 2.2.2.2 next-hop-self
//
配置下一跳自我,即对从
EBGP
邻居转入的路由,在通告给
IBGP
邻居的同时,强迫路由器通告自己是发送
BGP
更新的下一跳,而不是
EBGP
R3(config-router)#neighbor 6.6.6.6 remote-as 65001
R3(config-router)#neighbor 6.6.6.6 update-source loo0
R3(config-router)#neighbor 6.6.6.6 next-hop-self
R3(config-router)#neighbor 7.7.7.7 remote-as 65002
R3(config-router)#neighbor 7.7.7.7 update-source loo0
R3(config-router)#neighbor 7.7.7.7 ebgp-multihop 2
//
将邻居
7.7.7.7
的路数该为
2
,因为用的是环回口来建的邻居关系
R3(config)#ip route 7.7.7.7 255.255.255.255 192.168.37.7
R4
的配置命令
R4(config)#router bgp 65001
R4(config-router)#no synchronization
R4(config-router)#no auto-summary
R4(config-router)#bgp log-neighbor-changes
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#network 202.106.1.0 mask 255.255.255.0 //
把
M1
上的主机的
IP
地址通告出去
R4(config-router)#neighbor 2.2.2.2 remote-as 65001
R4(config-router)#neighbor 2.2.2.2 update-source loo0
R4(config-router)#neighbor 5.5.5.5 remote-as 65001
R4(config-router)#neighbor 5.5.5.5 update-source loo0
R5
的配置命令
R5(config)#router bgp 65001
R5(config-router)#no synchronization
R5(config-router)#no auto-summary
R5(config-router)#bgp log-neighbor-changes
R5(config-router)#bgp router-id 5.5.5.5
R5(config-router)# bgp cluster-id 10
R5(config-router)# neighbor 6.6.6.6 route-reflector-client //指定客户端为R6
R5(config-router)#neighbor 2.2.2.2 remote-as 65001
R5(config-router)#neighbor 2.2.2.2 update-source lo0
R5(config-router)#neighbor 4.4.4.4 remote-as 65001
R5(config-router)#neighbor 4.4.4.4 update-source lo0
R5(config-router)#neighbor 6.6.6.6 remote-as 65001
R5(config-router)#neighbor 6.6.6.6 update-source lo0