1.使用ENSP搭建的网络拓扑如下:
数据准备:
设备名称 |
接口 |
IP地址 |
DeviceA |
Loopback 0 |
1.1.1.1/32 |
Eth 1/0/0 |
172.16.0.1/16 |
|
Eth 0/0/0 |
192.168.0.1/24 |
|
DeviceB |
Loopback 0 |
2.2.2.2/32 |
Eth 0/0/1 |
10.1.1.1/24 |
|
GE 0/0/0 |
192.168.0.2/24 |
|
Eth 0/0/0 |
10.1.3.1/24 |
|
DeviceC |
Loopback 0 |
3.3.3.3/32 |
Eth 0/0/1 |
10.1.2.1/24 |
|
Eth 0/0/0 |
10.1.3.2/24 |
|
DeviceD |
Loopback 0 |
4.4.4.4/32 |
Eth 0/0/0 |
10.1.1.2/24 |
|
Eth 0/0/1 |
10.1.2.2/24 |
2.设备配置:
DeviceA配置如下:
<Huawei>display current-configuration interface LoopBack 0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
return
<Huawei>display current-configuration interface Ethernet0/0/0
#
interface Ethernet0/0/0
ip address 192.168.0.1 255.255.255.0
#
return
<Huawei>display current-configuration interface Ethernet0/0/1
#
interface Ethernet0/0/1
ip address 172.16.0.1 255.255.0.0
#
return
<Huawei>display current-configuration configuration bgp
#
bgp 65008
router-id 1.1.1.1
peer 192.168.0.2 as-number 65009
#
ipv4-family unicast
undo synchronization
network 172.16.0.0
peer 192.168.0.2 enable
#
return
<Huawei>
DeviceB配置如下:
<Huawei>dis current-configuration interface Ethernet0/0/0
#
interface Ethernet0/0/0
ip address 10.1.3.1 255.255.255.0
#
return
<Huawei>dis current-configuration interface Ethernet0/0/1
#
interface Ethernet0/0/1
ip address 10.1.1.1 255.255.255.0
#
return
<Huawei>dis current-configuration interface LoopBack0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
return
<Huawei>
<Huawei>dis cur config bgp
#
bgp 65009
router-id 2.2.2.2
peer 3.3.3.3 as-number 65009
peer 3.3.3.3 connect-interface LoopBack0
peer 4.4.4.4 as-number 65009
peer 4.4.4.4 connect-interface LoopBack0
peer 192.168.0.1 as-number 65008
#
ipv4-family unicast
undo synchronization
import-route direct
peer 3.3.3.3 enable
peer 4.4.4.4 enable
peer 192.168.0.1 enable
#
return
<Huawei>
DeviceC配置如下:
<Huawei>dis current-configuration interface Ethernet0/0/0
#
interface Ethernet0/0/0
ip address 10.1.3.2 255.255.255.0
#
return
<Huawei>dis current-configuration interface Ethernet0/0/1
#
interface Ethernet0/0/1
ip address 10.1.2.1 255.255.255.0
#
return
<Huawei>
<Huawei>dis current-configuration interface LoopBack0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
return
<Huawei>dis cur conf ospf
#
ospf 1
area 0.0.0.0
network 10.1.2.0 0.0.0.255
network 10.1.3.0 0.0.0.255
network 3.3.3.3 0.0.0.0
#
return
<Huawei>dis cur conf bgp
#
bgp 65009
router-id 3.3.3.3
peer 2.2.2.2 as-number 65009
peer 2.2.2.2 connect-interface LoopBack0
peer 4.4.4.4 as-number 65009
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 2.2.2.2 enable
peer 4.4.4.4 enable
#
return
<Huawei>
DeviceD配置如下:
<Huawei>dis cur interface Ethernet0/0/0
#
interface Ethernet0/0/0
ip address 10.1.1.2 255.255.255.0
#
return
<Huawei>dis cur interface Ethernet0/0/1
#
interface Ethernet0/0/1
ip address 10.1.2.2 255.255.255.0
#
return
<Huawei>dis cur interface LoopBack0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
return
<Huawei>
<Huawei>dis cur conf ospf
#
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 10.1.2.0 0.0.0.255
network 4.4.4.4 0.0.0.0
#
return
<Huawei>dis cur conf bgp
#
bgp 65009
router-id 4.4.4.4
peer 2.2.2.2 as-number 65009
peer 2.2.2.2 connect-interface LoopBack0
peer 3.3.3.3 as-number 65009
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 2.2.2.2 enable
peer 3.3.3.3 enable
#
return
<Huawei>
3.验证网络是否打通
在DeviceA上ping DeviceD 的接口地址:
4.分别查看每个设备上的路由
DeviceA的路由:
DeviceB的路由:
ospf 路由:
DeviceC的路由
deivceC的ospf路由:
DeviceD的路由
deviceD的ospf路由:
DeviceA1的路由:
5.路由学习抓包:
6.BGP路由配置和学习规律
1. BGP路由配置规律:
- 每个BGP路由器需要配置自身的自治系统号(AS号)。
- BGP路由器需要配置与其邻居建立对等体关系的IP地址。
- BGP路由器可以配置出口策略、过滤和转发规则等来控制路由的选择和传播。
2. BGP路由学习规律:
- BGP路由学习通常发生在边界路由器之间,即EBGP邻居之间,或者在同一个自治系统内的路由器之间,即IBGP邻居之间。
- BGP学习的路由信息包括目的地网络前缀、下一跳、AS路径和其他属性。
- 学习到的BGP路由信息会被存储在本地的BGP路由表中。
下面是一个示例图示,展示了两个自治系统(AS1和AS2)之间的BGP路由学习和传播的过程:
AS1 AS2
+---------------+ +---------------+
| R1 | | R3 |
|(EBGP Neighbor)| |(EBGP Neighbor)|
+------|--------+ +------|--------+
| |
| BGP Route Advertisement |
+------------------------------------------>|
| |
| BGP Route Learning |
|<------------------------------------------+
| |
在上述示例中,R1和R3分别是AS1和AS2的边界路由器,它们之间建立了EBGP邻居关系。
- 路由配置规律:
- R1需要配置自身的AS号为AS1,同时配置R3的IP地址作为EBGP邻居。
- R3需要配置自身的AS号为AS2,同时配置R1的IP地址作为EBGP邻居。
- 路由学习规律:
- R1向R3通告它所学习到的路由信息(目的地前缀、下一跳、AS路径等)。
- R3收到来自R1的BGP路由广告后,将其存储在本地的BGP路由表中,同时可以选择最佳路径进行转发。
- 如果R3也有其他的EBGP邻居,它还可以将学习到的路由信息传播给其他邻居。
BGP路由协议学习一