HCIP-IERS 部署企业级路由交换网络 - HCIP分解实验 - BGP基本配置 & BGP认证

目录

BGP 实验1:BGP基本配置

BGP实验2:BGP认证


BGP 实验1:BGP基本配置

早期发布的 BGP 的 3 个版本目前已经停止使用,当前使用的版本是 BGP-4 ,已经广泛应用于 ISP(Internet Service Provider)之间。

BGP虽然是一种动态路由协议 ,但它实际上本身并不产生路由、不发现路由、不计算路由,其主要功能是完成最佳路由的选择并在BGP邻居之间进行最佳路由的传递。BGP选择了TCP作为其传输协议,端口号为179.

BGP 支持无类域间路由 CIDR (Classless Inter-Domain Routing),并且采用了触发增量更新方式,这大大地减少了 BGP 在传播路由信息时占用的带宽,特别适用于在互联网上传播大量的路由信息。

BGP 提供了丰富的路由属性(Attribute),通过对这些属性的操作和控制,BGP 能够非常容易地实现丰富而灵活的路由策略。BGP 还具有良好的扩展性,支持 Multicast , VPN ,IPv6 等多种特性。

BGP 的邻居关系分为 IBGP (Internal BGP)和 EBGP (External BGP)两种:
当两台 BGP 路由器位于同一 AS 时(AS 编号相同),它们的邻居关系为 IBGP 邻居关系。
当两台 BGP 路由器位于不同的AS 时(AS 编号不同),它们的邻居关系为 EBGP 邻居关系。
BGP 没有自动建立邻居关系的能力,邻居关系必须通过手动配置来建立。可以通过物理接口,或环回口来建立邻居关系。

基本配置
R1:
undo ter mo
sys
sysname R1
user-interface console 0
idle-timeout 0 0
int loop 0
ip add 1.1.1.1 24
int g0/0/0
ip add 192.168.12.1 24
int g0/0/1
ip add 192.168.21.1 24
q

R2:
undo ter mo
sys
sysname R2
user-interface console 0
idle-timeout 0 0
int loop 0
ip add 2.2.2.2 24
int g0/0/0
ip add 192.168.12.2 24
int g0/0/2
ip add 192.168.21.2 24
int g0/0/1
ip add 192.168.23.2 24
int g0/0/3
ip add 192.168.32.2 24
q

R3:
undo ter mo
sys
sysname R3
user-interface console 0
idle-timeout 0 0
int loop 0
ip add 3.3.3.3 24
int g0/0/0
ip add 192.168.23.3 24
int g0/0/1
ip add 192.168.32.3 24
q

配置IBGP 邻居
使用物理接口建立邻居

R1:
bgp 100
router-id 1.1.1.1
peer 192.168.12.2 as-number 100
peer 192.168.21.2 as-number 100
q

R2:
bgp 100
router-id  2.2.2.2
peer 192.168.12.1 as-number 100
peer 192.168.21.1 as-number 100

[R2]display bgp peer

在R1 上将环回口 0通告到BGP 进程中
R1:
bgp 100
network 1.1.1.0 24

[R2]display bgp routing-table

=========
使用环回口来建立BGP 邻居
使用Loopback 接口建立BGP邻居关系比使用物理接口建立相比较,前者具有更好的稳定性,且能够减少设备资源的开销。

R1:
ip route-static 2.2.2.0 255.255.255.0 192.168.12.2
ip route-static 2.2.2.0 255.255.255.0 192.168.21.2
bgp 100
undo peer 192.168.12.2
undo peer 192.168.21.2
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack 0

R2:
ip route-static 1.1.1.0 255.255.255.0 192.168.12.1
ip route-static 1.1.1.0 255.255.255.0 192.168.21.1
bgp 100
undo peer 192.168.12.1
undo peer 192.168.21.1
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack 0

[R2]display bgp peer 邻居也能正常建立

配置EBGP邻居
使用Loopback 0 接口来建立EBGP邻居
R2:
ip route-static 3.3.3.0 255.255.255.0 192.168.23.3
ip route-static 3.3.3.0 255.255.255.0 192.168.32.3

bgp 100
peer 3.3.3.3 as-number 200
peer 3.3.3.3 connect-interface LoopBack 0
peer 3.3.3.3 ebgp-max-hop

R3:
ip route-static 2.2.2.0 255.255.255.0 192.168.23.2
ip route-static 2.2.2.0 255.255.255.0 192.168.32.2
bgp 200
router-id 3.3.3.3
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack 0
peer 2.2.2.2 ebgp-max-hop 255

<R2>display bgp peer 邻居建立成功

通常使用LoopBack 接口建立 IBGP邻居,使用物理接口建立EBGP邻居


BGP实验2:BGP认证

物理接口IP地址来建立BGP邻居关系

认证是指路由器对路由信息来源的可靠性及路由信息本身的完整性进行检测的机制。


基本配置、配置BGP路由协议
R1:
undo ter mo
sys
sysname R1
int loop 0
ip add 1.1.1.1 24
int g0/0/0
ip add 192.168.12.1 24
q

bgp 100
router-id 1.1.1.1
peer 192.168.12.2 as-number 100
q

R2:
undo ter mo
sys
sysname R2
int loop 0
ip add 2.2.2.2 24
int g0/0/0
ip add 192.168.12.2 24
int g0/0/1
ip add 192.168.23.2 24
q

bgp 100
router-id 2.2.2.2
peer 192.168.12.1 as-number 100
peer 192.168.23.3 as-number 200
q

R3:
undo ter mo
sys
sysname R3
int loop 0
ip add 3.3.3.3 24
int g0/0/1
ip add 192.168.23.3 24
q

bgp 200
router-id 3.3.3.3
peer 192.168.23.2 as-number 100
q
配置完成后 BGP 邻居建立正常
<R2>display bgp peer

=========

配置基于单一密钥的BGP认证功能

R1:
bgp 100
peer 192.168.12.2 password simple huawei

正常的 keepalive 60 hold 180
时间太长,认证之后,效果不明显,可以将计时器改的小一些

修改计时器
bgp 100
timer keepalive 5 hold 15


R1 做认证,R2 没做,邻居不能正常建立

R2:
bgp 100
peer 192.168.12.1 password simple huawei
peer 192.168.23.3 password cipher huawei
R3:
bgp 200
peer 192.168.23.2 password simple huawei
cipher密钥会被加密,simpler是明文显示,但不影响邻居的建立

=========

配置基于Keychain的BGP认证

选用Periodic Daily模式,每天 8点到 18 使用key-id 1对BGP报文做hash运算。
先删掉R1 R2 上的简单认证

R1:
bgp 100
undo peer 192.168.12.2 password
R2:
bgp 100
undo peer 192.168.12.1 password

接着做 key chain 方式的认证

absolute 绝对时间 periodic 周期时间

R1:
keychain key mode periodic daily
key-id 1
algorithm md5
key-string huawei
send-time daily 08:00 to 18:00
receive-time daily 08:00 to 18:00
bgp 100
peer 192.168.12.2 keychain key

R2:
keychain key mode periodic daily
key-id 1
algorithm md5
key-string huawei
send-time daily 08:00 to 18:00
receive-time daily 08:00 to 18:00
bgp 100
peer 192.168.12.1 keychain key

[R1]display bgp peer 邻居关系是正常的
[R1]display keychain key

猜你喜欢

转载自blog.csdn.net/weixin_57099902/article/details/132469506