拓扑图
实现效果:
PC1与PC2互通
AR1、AR2、AR3三台路由运行RIP/OSPF协议
左边BGP100,右边BGP200
AR4、AR5运行IBGP
1.两台PC配置IP
PC1:100.1.1.1,掩码:255.255.255.0,网关:100.1.1.1.254
PC2:200.1.1.1,掩码:255.255.255.0,网关:200.1.1.1.254
2.AR1配置各个接口的地址
g0/0/0端口IP:100.1.1.254/24
g/0/0/1端口IP:12.1.1.1/30
g/0/0/2端口IP:13.1.1.1/30
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname AR1
[AR1]interface gigabitether 0/0/0
[AR1-GigabitEthernet0/0/0]ip address 100.1.1.254 24
[AR1-GigabitEthernet0/0/0]quit
[AR1]interface gigabitether 0/0/1
[AR1-GigabitEthernet0/0/1]ip address 12.1.1.1 30
[AR1-GigabitEthernet0/0/1]quit
[AR1]interface gigabitether 0/0/2
[AR1-GigabitEthernet0/0/2]ip address 13.1.1.1 30
[AR1-GigabitEthernet0/0/2]quit
[AR1]
3.AR2配置各个接口地址
g0/0/0:12.1.1.2/30
g0/0/1:23.1.1.2/30
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname AR2
[AR2]interface gigabitether 0/0/0
[AR2-GigabitEthernet0/0/0]ip address 12.1.1.2 30
[AR2-GigabitEthernet0/0/0]quit
[AR2]interface gigabitether 0/0/1
[AR2-GigabitEthernet0/0/1]ip address 23.1.1.2 30
[AR2-GigabitEthernet0/0/1]quit
[AR2]
4.AR3配置各个接口地址
g0/0/0:13.1.1.2/30
g0/0/1:23.1.1.1/30
g0/0/2:34.1.1.2/30
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname AR3
[AR3]interface gigabitether 0/0/0
[AR3-GigabitEthernet0/0/0]ip address 13.1.1.2 30
[AR3-GigabitEthernet0/0/0]quit
[AR3]interface gigabitether 0/0/1
[AR3-GigabitEthernet0/0/1]ip address 23.1.1.1 30
[AR3-GigabitEthernet0/0/1]quit
[AR3]interface gigabitether 0/0/2
[AR3-GigabitEthernet0/0/2]ip address 34.1.1.1 30
[AR3-GigabitEthernet0/0/2]quit
[AR3]
5.AR4配置各个接口地址
g0/0/0:34.1.1.2/30
g0/0/1:45.1.1.1/30
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname AR4
[AR4]interface gigabitether 0/0/0
[AR4-GigabitEthernet0/0/0]ip address 34.1.1.2 30
[AR4-GigabitEthernet0/0/0]quit
[AR4]interface gigabitether 0/0/1
[AR4-GigabitEthernet0/0/1]ip address 45.1.1.1 30
[AR4-GigabitEthernet0/0/1]quit
[AR4]
6.AR5配置各个接口地址
g0/0/0:45.1.1.2/30
g0/0/1:200.1.1.254/24
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname AR5
[AR5]interface gigabitether 0/0/0
[AR5-GigabitEthernet0/0/0]ip address 45.1.1.2 30
[AR5-GigabitEthernet0/0/0]quit
[AR5]interface gigabitether 0/0/1
[AR5-GigabitEthernet0/0/1]ip address 200.1.1.254 24
[AR5-GigabitEthernet0/0/1]quit
[AR5]
7.检查配置
所有直连设备是否能通,不用互ping,一边能ping通另一边一定能通
方法1:PC1pingAR1、AR1pingAR2、AR1pingAR3……以此类推
方法2:每台设备运行display ip routing-table查看每台设备的路由表是否学习到相邻的地址
8.AR1、AR2、AR3三台路由运行RIP
注:RIP只需要宣告主类网络,一般都是运行rip2,rip1、2版本对比是经常考的
AR1配置
[AR1]rip
[AR1-rip-1]version 2
[AR1-rip-1]network 100.0.0.0
[AR1-rip-1]network 12.0.0.0
[AR1-rip-1]network 13.0.0.0
[AR1-rip-1]quit
AR2配置
[AR2]rip
[AR2-rip-1]version 2
[AR2-rip-1]network 12.0.0.0
[AR2-rip-1]network 23.0.0.0
[AR2-rip-1]quit
[AR2]
AR3配置
[AR3]rip
[AR3-rip-1]version 2
[AR3-rip-1]network 23.0.0.0
[AR3-rip-1]network 13.0.0.0
[AR3-rip-1]quit
验证检查
此时AR1、AR2、AR3运行 display ip routing-table 应该可以看到3台路由的地址都能相互学习到
用PC1 ping 三台路由器上的任意地址都能通
9.AR1、AR2、AR3三台路由运行OSPF
前面配置过rip了,得先把3台路由器上的rip删除再配置OSPF
AR1、AR2、AR3都运行:undo rip 1 ,输入y确认删除
[AR1]undo rip 1
Warning: The RIP process will be deleted. Continue?[Y/N]y
[AR1]
[AR2]undo rip 1
Warning: The RIP process will be deleted. Continue?[Y/N]y
[AR2]
[AR3]undo rip 1
Warning: The RIP process will be deleted. Continue?[Y/N]y
[AR3]
配置OSPF
注:OSPF宣告网络需要反掩码
AR1配置
[AR1]ospf
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]network 100.1.1.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.3
[AR1-ospf-1-area-0.0.0.0]network 13.1.1.0 0.0.0.3
[AR1-ospf-1-area-0.0.0.0]quit
[AR1-ospf-1]quit
[AR1]
AR2配置
[AR2]ospf
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.3
[AR2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.3
[AR2-ospf-1-area-0.0.0.0]quit
[AR2-ospf-1]quit
[AR2]
AR3配置
[AR3]ospf
[AR3-ospf-1]area 0
[AR3-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.3
[AR3-ospf-1-area-0.0.0.0]network 13.1.1.0 0.0.0.3
[AR3-ospf-1-area-0.0.0.0]quit
[AR3-ospf-1]quit
[AR3]
验证检查
此时用PC3 pingAR1、AR2、AR3任意地址都可以通
路由跟踪PC1到AR3的23.1.1.1地址走的最近路径(AR1→AR3),把AR1的g0/0/2端口shutdown掉模拟线路故障还是能通走的上面路径(AR1→AR2→AR3)
PC>tracert 23.1.1.1
traceroute to 23.1.1.1, 8 hops max
(ICMP), press Ctrl+C to stop
1 100.1.1.254 16 ms 16 ms 15 ms
2 23.1.1.1 16 ms 15 ms 16 ms
PC>tracert 23.1.1.1
traceroute to 23.1.1.1, 8 hops max
(ICMP), press Ctrl+C to stop
1 100.1.1.254 16 ms <1 ms 15 ms
2 12.1.1.2 31 ms 16 ms 31 ms
3 23.1.1.1 16 ms 62 ms 16 ms
PC>
10.配置BGP
AR3配置
对端是AR4的g0/0/0(34.1.1.2)BGP200
[AR3]bgp 100
[AR3-bgp]peer 34.1.1.2 as-number 200
[AR3-bgp]quit
AR4配置
左边ebgp 对端AR3的g0/0/2(34.1.1.1)BGP100
右边ibgp 对端AR5的g0/0/0(45.1.1.2)BGP200
[AR4]bgp 200
[AR4-bgp]peer 34.1.1.1 as-number 100
[AR4-bgp]peer 45.1.1.2 as-number 200
[AR4-bgp]quit
[AR4]
AR5配置
对端AR4的g0/0/1(45.1.1.1)BGP200
[AR5]bgp 200
[AR5-bgp]peer 45.1.1.1 as-number 200
[AR5-bgp]quit
[AR5]
检查是否建立关系
在AR3、AR4、AR5运行:display bgp peer 查看 ,Established表示建立连接
[AR3]display bgp peer
BGP local router ID : 13.1.1.2
Local AS number : 100
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
34.1.1.2 4 200 27 28 0 00:25:40 Established
0
[AR3]
[AR4]display bgp peer
BGP local router ID : 34.1.1.2
Local AS number : 200
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
34.1.1.1 4 100 27 27 0 00:25:28 Established
0
45.1.1.2 4 200 9 10 0 00:07:01 Established
0
[AR4]
[AR5]display bgp peer
BGP local router ID : 45.1.1.2
Local AS number : 200
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
45.1.1.1 4 200 4 4 0 00:02:16 Established
0
[AR5]
11.引入路由
AR3、AR4、AR5的BGP邻居关系已经建立了,但是路由还没有
AR5配置(引入PC2的200网段)
通过ipv4单播路由宣告下面PC2的网段进来
[AR5]bgp 200
[AR5-bgp]ipv4-family unicast
[AR5-bgp-af-ipv4]network 200.1.1.0 24
[AR5-bgp-af-ipv4]quit
[AR5-bgp]
然后AR4通过ibgp学到了
AR3通过ebgp学到了
这时候AR3、AR4、AR5有BGP邻居关系都学习到了PC2的路由,但是AR1和AR2还没有PC的路由
AR3配置(BGP的路由引入到OSPF里面)
在AR3路由器上进入ospf导入BGP
[AR3]
[AR3]ospf
[AR3-ospf-1]import-route bgp
[AR3-ospf-1]quit
[AR3]
这时候去AR1、AR2路由器上查看路由表就有PC2的路由了
还是AR3配置(OSPF路由引入到BGP)
上面BGP路由引入到OSPF使得所有路由器都有PC2的路由了,但是此时AR4、AR5没有PC1的路由,单边通了回程回不去也是不通的
[AR3]bgp 100
[AR3-bgp]import-route ospf 1
[AR3-bgp]quit
[AR3]
这个时候再去查看AR4、AR5的路由表
但是查询AR5的路由表会发现没有100网段的路由
AR5配置
查看bgp表可以看见已经学习到了100网段的路由,但是没有加表。可以看到NextHop下一跳是34.1.1.1也就是AR3的g0/0/2接口的地址,而AR5是没有34的路由的不可达
[AR5]display bgp routing-table
BGP Local router ID is 45.1.1.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 5
Network NextHop MED LocPrf PrefVal Path/Ogn
i 12.1.1.0/30 34.1.1.1 2 100 0 100?
i 13.1.1.0/30 34.1.1.1 0 100 0 100?
i 23.1.1.0/30 34.1.1.1 0 100 0 100?
i 100.1.1.0/24 34.1.1.1 2 100 0 100?
*> 200.1.1.0 0.0.0.0 0 0 i
[AR5]
方法1:可以写个静态路由指定,去往34的地址就甩给AR4的g0/0/1接口(45.1.1.1)
[AR5]
[AR5]ip route-static 34.1.1.0 30 45.1.1.1
[AR5]
添加静态路由后再查看路由表,有了PC1的路由了
AR4配置
方法2:先把前面静态路由删除,然后去AR4配置宣告网络的时候把下一跳指向自己
AR5删除静态路由
[AR5]undo ip route-static 34.1.1.0 30 45.1.1.1
AR4配置
[AR4]bgp 200
[AR4-bgp]peer 45.1.1.2 next-hop-local
[AR4-bgp]
[AR4-bgp]quit
[AR4]
AR5也可以学到PC1的路由
查看bgp路由表会发现,下一跳变成45.1.1.1了
[AR5]dis bgp routing-table
BGP Local router ID is 45.1.1.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 5
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 12.1.1.0/30 45.1.1.1 2 100 0 100?
*>i 13.1.1.0/30 45.1.1.1 0 100 0 100?
*>i 23.1.1.0/30 45.1.1.1 0 100 0 100?
*>i 100.1.1.0/24 45.1.1.1 2 100 0 100?
*> 200.1.1.0 0.0.0.0 0 0 i
[AR5]
12.验证成果
PC1和PC2可以互通了,可以使用tracert跟踪路由查看路由走向,因为是动态路由OSPF会自动收敛,把AR1的g0/0/2接口关闭或者线路删掉会自动走上面通过AR2到达AR1的g0/0/1再到达PC1
评论区