实验明细
- 实验拓扑
- 实验要求
- 实验内容
实验拓扑
实验要求
1.R2-R7每台路由器均存在一个环回接口用于建立邻居;同时还存在一个环回来代表连接用户的接口;最终这些连接用户的接口网络需要可以和R1/8的环回通讯
2.AS2网段地址为172.16.0.0/16,减少路由条目数量
实验内容
IP地址的划分
R1:
环回1.1.1.1/24 R1/2网段12.1.1.0/24
R2/3网段 172.16.1.0/30
R3/4网段 172.16.1.4/30
R4/7网段 172.16.1.8/30
R6/7网段 172.16.1.12/30
R5/6网段 172.16.1.16/30
R2/5网段 172.16.1.20/30
R2两个环回:172.16.2.1/24 172.16.0.2/32
R3: 172.16.3.1/24 172.16.0.3/32
R4: 172.16.4.1/24 172.16.0.4/32
R5 :172.16.5.1/24 172.16.0.5/32
R6 : 172.16.6.1/24 172.16.0.6/32
R7 : 172.16.7.1/24 172.16.0.7/32
R7/8: 78.1.1.0/24
R8:8.8.8.8/24
ip地址规划完成,开始给每台路由器配置ip地址
R1
[r1]int lo0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1-LoopBack0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
R2
[r2]int lo0
[r2-LoopBack0]ip add 172.16.0.2 32
[r2-LoopBack0]int lo1
[r2-LoopBack1]ip add 172.16.2.1 24
[r2-LoopBack1]int g0/0/0
[r2-GigabitEthernet0/0/0]ip ad 12.1.1.2 24
Aug 6 2022 21:10:14-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 172.16.1.1 30
R3
[r3]int lo0
[r3-LoopBack0]ip add 172.16.0.3 32
[r3-LoopBack0]int lo1
[r3-LoopBack1]ip add 172.16.3.1 24
[r3-LoopBack1]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 172.16.1.2 30
Aug 6 2022 21:11:29-08:00 r3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 172.16.1.5 30
R4
[r4]int lo0
[r4-LoopBack0]ip add 172.16.0.4 32
[r4-LoopBack0]int lo1
[r4-LoopBack1]ip add 172.16.4.1 24
[r4-LoopBack1]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 172.16.1.6 30
Aug 6 2022 21:12:39-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[r4-GigabitEthernet0/0/0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 172.16.1.9 30
R5
[Huawei]sys r5
[r5]int lo0
[r5-LoopBack0]ip add 172.16.0.5 32
[r5-LoopBack0]int lo1
[r5-LoopBack1]ip add 172.16.5.1 24
[r5-LoopBack1]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 172.16.1.17 30
Aug 6 2022 21:16:15-08:00 r5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[r5-GigabitEthernet0/0/0]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 172.16.1.22 30
R6
[r6]int lo0
[r6-LoopBack0]ip add 172.16.0.6 32
[r6-LoopBack0]int lo1
[r6-LoopBack1]ip add 172.16.6.1 24
[r6-LoopBack1]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 172.16.1.13 30
Aug 6 2022 21:15:14-08:00 r6 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[r6-GigabitEthernet0/0/0]int g0/0/1
[r6-GigabitEthernet0/0/1]ip add 172.16.1.18 30
R7
[r7]int lo0
[r7-LoopBack0]ip add 172.16.0.7 32
[r7-LoopBack0]int lo1
[r7-LoopBack1]ip add 172.16.7.1 24
[r7-LoopBack1]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 172.16.1.10 30
Aug 6 2022 21:13:47-08:00 r7 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[r7-GigabitEthernet0/0/0]int g0/0/1
[r7-GigabitEthernet0/0/1]ip add 172.16.1.14 30
Aug 6 2022 21:14:08-08:00 r7 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[r7-GigabitEthernet0/0/1]int g0/0/2
[r7-GigabitEthernet0/0/2]ip add 78.1.1.1 24
R8
[r8]int lo0
[r8-LoopBack0]ip add 8.8.8.8 24
[r8-LoopBack0]int g0/0/0
[r8-GigabitEthernet0/0/0]ip add 78.1.1.2 24
地址配置完成,在整个AS2区域内起ospf 协议 。
使用ospf协议跑通AS2,进行互相建邻居。
R2
[r2]ospf 1
[r2-ospf-1]a 0
[r2-ospf-1-area-0.0.0.0]net
[r2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R3
[r3]ospf 1
[r3-ospf-1]a 0
[r3-ospf-1-area-0.0.0.0]net
[r3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
R4
[r4]ospf 1
[r4-ospf-1]a 0
[r4-ospf-1-area-0.0.0.0]net
[r4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
剩下的配置都是相同的,因为AS 2中的ip地址都是基于172.16.0.0/16划分所得的。
然后
简单的检查一下ospf建立邻居的情况
[r2]display ospf peer brief
OSPF Process 1 with Router ID 172.16.0.2
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1 172.16.0.3 Full
0.0.0.0 GigabitEthernet0/0/2 172.16.0.5 Full
----------------------------------------------------------------------------
<r5>display ospf peer brief
OSPF Process 1 with Router ID 172.16.0.5
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 172.16.0.6 Full
0.0.0.0 GigabitEthernet0/0/1 172.16.0.2 Full
----------------------------------------------------------------------------
邻居关系建立无误
接着,开始建立BGP对等体关系
R1,2和R7,8之间为了方便,采用直连建邻,用环回建邻也可以
R1,2
[r1]bgp 1
[r1-bgp]router
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as
[r1-bgp]peer 12.1.1.2 as-number 2
[r2]bgp 64512
[r2-bgp]router
[r2-bgp]router-id 2.2.2.2
[r2-bgp]con
[r2-bgp]confederation id 2
[r2-bgp]peer 12.1.1.1 as
[r2-bgp]peer 12.1.1.1 as-number 1
R7,8与R1,2之间建立方法一致
AS2之间的bgp对等体关系
R2
[r2]
[r2]bgp 64512
[r2-bgp]peer 172.16.0.3 as
[r2-bgp]peer 172.16.0.3 as-number 64512
[r2-bgp]peer 172.16.0.3 connect-interface LoopBack 0
[r2-bgp]peer 172.16.0.3 ne
[r2-bgp]peer 172.16.0.3 next-hop-invariable
[r2-bgp]peer 172.16.0.3 next-hop-local
[r2]bgp 64512
[r2-bgp]peer 172.16.0.4 as
[r2-bgp]peer 172.16.0.4 as-number 64512
[r2-bgp]peer 172.16.0.4 connect-interface LoopBack 0
[r2-bgp]peer 172.16.0.4 ne
[r2-bgp]peer 172.16.0.4 next-hop-invariable
[r2-bgp]peer 172.16.0.4 next-hop-local
[r2]bgp 64512
[r2-bgp]confederation id 2
[r2-bgp]conf
[r2-bgp]confederation peer
[r2-bgp]confederation peer-as 64513
[r2-bgp]peer 172.16.0.5 as
[r2-bgp]peer 172.16.0.5 as-number 64513
[r2-bgp]peer 172.16.0.5 con
[r2-bgp]peer 172.16.0.5 connect-interface lo
[r2-bgp]peer 172.16.0.5 connect-interface LoopBack 0
[r2-bgp]peer 172.16.0.5 ne
[r2-bgp]peer 172.16.0.5 ebg
[r2-bgp]peer 172.16.0.5 ebgp-max-hop 2
[r2-bgp]peer 172.16.0.5 ne
[r2-bgp]peer 172.16.0.5 next-hop-invariable
[r2-bgp]peer 172.16.0.5 next-hop-local
R3
[r3]bgp 64512
[r3-bgp]router
[r3-bgp]router-id 3.3.3.3
[r3-bgp]con
[r3-bgp]confederation id 2
[r3-bgp]peer 172.16.0.2 as
[r3-bgp]peer 172.16.0.2 as-number 64512
[r3-bgp]peer 172.16.0.2 con
[r3-bgp]peer 172.16.0.2 connect-interface lo
[r3-bgp]peer 172.16.0.2 connect-interface LoopBack 0
[r3-bgp]peer 172.16.0.2 ne
[r3-bgp]peer 172.16.0.2 next-hop-invariable
[r3-bgp]peer 172.16.0.2 next-hop-local
R4
[r4]bgp 64512
[r4-bgp]router
[r4-bgp]router-id 4.4.4.4
[r4-bgp]con
[r4-bgp]confederation id 2
[r4-bgp]peer 172.16.0.2 as
[r4-bgp]peer 172.16.0.2 as-number 64512
[r4-bgp]peer 172.16.0.2 con
[r4-bgp]peer 172.16.0.2 connect-interface lo
[r4-bgp]peer 172.16.0.2 connect-interface LoopBack 0
[r4-bgp]peer 172.16.0.2 ne
[r4-bgp]peer 172.16.0.2 next-hop-invariable
[r4-bgp]peer 172.16.0.2 next-hop-local
[r4]bgp 64512
[r4-bgp]con
[r4-bgp]confederation id 2
[r4-bgp]con
[r4-bgp]confederation peer
[r4-bgp]confederation peer-as 64513
[r4-bgp]peer 172.16.0.7 as
[r4-bgp]peer 172.16.0.7 as-number 64513
[r4-bgp]peer 172.16.0.7 con
[r4-bgp]peer 172.16.0.7 connect-interface lo
[r4-bgp]peer 172.16.0.7 connect-interface LoopBack 0
[r4-bgp]peer 172.16.0.7 eb
[r4-bgp]peer 172.16.0.7 ebgp-max-hop 2
[r4-bgp]peer 172.16.0.7 ne
[r4-bgp]peer 172.16.0.7 next-hop-invariable
[r4-bgp]peer 172.16.0.7 next-hop-local
R5
[r5]bgp 64513
[r5-bgp]router
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 172.16.0.6 as
[r5-bgp]con
[r5-bgp]confederation id 2
[r5-bgp]peer 172.16.0.6 as
[r5-bgp]peer 172.16.0.6 as-number 64513
[r5-bgp]peer 172.16.0.6 con
[r5-bgp]peer 172.16.0.6 connect-interface lo
[r5-bgp]peer 172.16.0.6 connect-interface LoopBack 0
[r5-bgp]peer 172.16.0.6 ne
[r5-bgp]peer 172.16.0.6 next-hop-invariable
[r5-bgp]peer 172.16.0.6 next-hop-local
[r5-bgp]peer 172.16.0.7 as
[r5-bgp]peer 172.16.0.7 as-number 64513
[r5-bgp]peer 172.16.0.7 con
[r5-bgp]peer 172.16.0.7 connect-interface lo
[r5-bgp]peer 172.16.0.7 connect-interface LoopBack 0
[r5-bgp]peer 172.16.0.7 ne
[r5-bgp]peer 172.16.0.7 next-hop-invariable
[r5-bgp]peer 172.16.0.7 next-hop-local
[r5]bgp 64513
[r5-bgp]con
[r5-bgp]confederation id 2
[r5-bgp]con
[r5-bgp]confederation peer
[r5-bgp]confederation peer-as 64512
[r5-bgp]peer 172.16.0.2 as
[r5-bgp]peer 172.16.0.2 as-number 64512
[r5-bgp]peer 172.16.0.2 con
[r5-bgp]peer 172.16.0.2 connect-interface lo
[r5-bgp]peer 172.16.0.2 connect-interface LoopBack 0
[r5-bgp]peer 172.16.0.2 eb
[r5-bgp]peer 172.16.0.2 ebgp-max-hop 2
[r5-bgp]peer 172.16.0.2 ne
[r5-bgp]peer 172.16.0.2 next-hop-invariable
[r5-bgp]peer 172.16.0.2 next-hop-local
R6
[r6]bgp 64513
[r6-bgp]router
[r6-bgp]router-id 6.6.6.6
[r6-bgp]con
[r6-bgp]confederation id 2
[r6-bgp]peer 172.16.0.5 as
[r6-bgp]peer 172.16.0.5 as-number 64513
[r6-bgp]peer 172.16.0.7 as
[r6-bgp]peer 172.16.0.7 as-path-filter
[r6-bgp]peer 172.16.0.5 con
[r6-bgp]peer 172.16.0.5 connect-interface
[r6-bgp]peer 172.16.0.5 connect-interface lo
[r6-bgp]peer 172.16.0.5 connect-interface LoopBack 0
[r6-bgp]peer 172.16.0.5 ne
[r6-bgp]peer 172.16.0.5 next-hop-invariable
[r6-bgp]peer 172.16.0.5 next-hop-local
R7
[r7]bgp 64513
[r7-bgp]con
[r7-bgp]router
[r7-bgp]router-id 7.7.7.7
[r7-bgp]con
[r7-bgp]confederation id 2
[r7-bgp]peer 172.16.0.5 as
[r7-bgp]peer 172.16.0.5 as-number 64513
[r7-bgp]peer 172.16.0.5 con
[r7-bgp]peer 172.16.0.5 connect-interface lo
[r7-bgp]peer 172.16.0.5 connect-interface LoopBack 0
[r7-bgp]peer 172.16.0.5 ne
[r7-bgp]peer 172.16.0.5 next-hop-invariable
[r7-bgp]peer 172.16.0.5 next-hop-local
[r7-bgp]peer 78.1.1.2 as
[r7-bgp]peer 78.1.1.2 as-number 3
[r7]bgp 64513
[r7-bgp]con
[r7-bgp]confederation id 2
[r7-bgp]con
[r7-bgp]confederation peer
[r7-bgp]confederation peer-as 64512
[r7-bgp]peer 172.16.0.4 as
[r7-bgp]peer 172.16.0.4 as-number 64512
[r7-bgp]peer 172.16.0.4 con
[r7-bgp]peer 172.16.0.4 connect-interface lo
[r7-bgp]peer 172.16.0.4 connect-interface LoopBack 0
[r7-bgp]peer 172.16.0.4 eb
[r7-bgp]peer 172.16.0.4 ebgp-max-hop 2
[r7-bgp]peer 172.16.0.4 ne
[r7-bgp]peer 172.16.0.4 next-hop-invariable
[r7-bgp]peer 172.16.0.4 next-hop-local
在R3和R6上做一个发射器,不然无法传递路由
R3
[r3]bgp 64512
[r3-bgp]con
[r3-bgp]confederation id 2
[r3-bgp]peer 172.16.0.2 re
[r3-bgp]peer 172.16.0.2 reflect-client
R6
[r6]bgp 64513
[r6-bgp]peer 172.16.0.5 reflect-client
简单的检查一些bgp邻居的建立情况
[r7-bgp]display bgp peer
BGP local router ID : 7.7.7.7
Local AS number : 64513
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
78.1.1.2 4 3 12 14 0 00:10:40 Established 0
172.16.0.4 4 64512 2 2 0 00:00:43 Established 0
172.16.0.5 4 64513 13 13 0 00:11:52 Established 0
[r2-bgp]display bgp peer
BGP local router ID : 2.2.2.2
Local AS number : 64512
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
12.1.1.1 4 1 14 14 0 00:12:21 Established 0
172.16.0.3 4 64512 2 2 0 00:00:26 Established 0
172.16.0.4 4 64512 7 7 0 00:05:08 Established 0
我们可以发现,bgp邻居建立关系没有问题
我们可以在R1 和R8 上宣告一条路由
R1
[r1]bgp 1
[r1-bgp]net
[r1-bgp]network 1.1.1.0 24
R8
[r8]bgp 3
[r8-bgp]net
[r8-bgp]network 8.8.8.0 24
在其他路由器上 查看是否有这些路由
R2
<r2>display bgp routing-table
BGP Local router ID is 2.2.2.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: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.0/24 12.1.1.1 0 0 1i
*>i 8.8.8.0/24 172.16.0.7 0 100 0 (64513) 3i
R4
[r4-bgp]display bgp routing-table
BGP Local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.0/24 172.16.0.2 0 100 0 1i
*>i 8.8.8.0/24 172.16.0.7 0 100 0 (64513) 3i
* i 172.16.0.7 0 100 0 (64513) 3i
为了R1能ping通各个路由器的用户网段,我们需要将他们的用户网段进行宣告
查看他们的路由表
R4
<r4>display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 30 Routes : 32
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 IBGP 255 0 RD 172.16.0.2 GigabitEthernet0/0/0
8.8.8.0/24 IBGP 255 0 RD 172.16.0.7 GigabitEthernet0/0/1
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.16.0.2/32 OSPF 10 2 D 172.16.1.5 GigabitEthernet0/0/0
172.16.0.3/32 OSPF 10 1 D 172.16.1.5 GigabitEthernet0/0/0
172.16.0.4/32 Direct 0 0 D 127.0.0.1 LoopBack0
172.16.0.5/32 OSPF 10 3 D 172.16.1.5 GigabitEthernet0/0/0
OSPF 10 3 D 172.16.1.10 GigabitEthernet0/0/1
172.16.0.6/32 OSPF 10 2 D 172.16.1.10 GigabitEthernet0/0/1
172.16.0.7/32 OSPF 10 1 D 172.16.1.10 GigabitEthernet0/0/1
172.16.1.0/30 OSPF 10 2 D 172.16.1.5 GigabitEthernet0/0/0
172.16.1.4/30 Direct 0 0 D 172.16.1.6 GigabitEthernet0/0/0
172.16.1.6/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
172.16.1.7/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
172.16.1.8/30 Direct 0 0 D 172.16.1.9 GigabitEthernet0/0/1
172.16.1.9/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
172.16.1.11/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
172.16.1.12/30 OSPF 10 2 D 172.16.1.10 GigabitEthernet0/0/1
172.16.1.16/30 OSPF 10 3 D 172.16.1.10 GigabitEthernet0/0/1
172.16.1.20/30 OSPF 10 3 D 172.16.1.5 GigabitEthernet0/0/0
172.16.2.1/32 OSPF 10 2 D 172.16.1.5 GigabitEthernet0/0/0
172.16.3.1/32 OSPF 10 1 D 172.16.1.5 GigabitEthernet0/0/0
172.16.4.0/24 Direct 0 0 D 172.16.4.1 LoopBack1
172.16.4.1/32 Direct 0 0 D 127.0.0.1 LoopBack1
172.16.4.255/32 Direct 0 0 D 127.0.0.1 LoopBack1
172.16.5.1/32 OSPF 10 3 D 172.16.1.5 GigabitEthernet0/0/0
---- More ----
我们可以发现 他们的用户网段都是为32 位的
那是因为在ospf中宣告的环回都是为32 位
我们需要将他们改为24位,只需要将接口类型修改为broadcast
R7
[r7]int lo0
[r7-LoopBack0]ospf net
[r7-LoopBack0]ospf network-type b
[r7-LoopBack0]ospf network-type broadcast
R3
[r3]int lo0
[r3-LoopBack0]ospf net
[r3-LoopBack0]ospf network-type b
[r3-LoopBack0]ospf network-type broadcast
其余的修改都是一样的
再次查看路由表发现都已经修改为24位了
接着在进行宣告
R2上
[r2]bgp 64512
[r2-bgp]net
[r2-bgp]network 172.16.2.0 24
用R1来pingR2的用户网段
<r1>ping -a 1.1.1.1 172.16.2.1
PING 172.16.2.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.1: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 172.16.2.1: bytes=56 Sequence=2 ttl=255 time=10 ms
Reply from 172.16.2.1: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 172.16.2.1: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 172.16.2.1: bytes=56 Sequence=5 ttl=255 time=20 ms
R1 ping R8
<r1>ping -a 1.1.1.1 8.8.8.8
PING 8.8.8.8: 56 data bytes, press CTRL_C to break
Reply from 8.8.8.8: bytes=56 Sequence=1 ttl=251 time=60 ms
Reply from 8.8.8.8: bytes=56 Sequence=2 ttl=251 time=50 ms
Reply from 8.8.8.8: bytes=56 Sequence=3 ttl=251 time=50 ms
Reply from 8.8.8.8: bytes=56 Sequence=4 ttl=251 time=50 ms
Reply from 8.8.8.8: bytes=56 Sequence=5 ttl=251 time=40 ms
--- 8.8.8.8 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/50/60 ms
发现可以ping通
最后就进行路由汇总了
R2
[r1-bgp]aggregate 172.16.0.0 21
先逐条宣告本地所有明细路由,在进行汇总,会自动生成空接口防环路由
最后 实验结束!