规划网段,配置路由,写缺省路由
R1:
G 0/0/1 16.0.0.1 24
G 0/0/0 116.0.0.1 24
L0 192.168.1.1 24
R2:
G 0/0/0 26.0.0.1 24
L0 192.168.2.1 24
R3:
G 0/0/0 36.0.0.1 24
L0 192.168.3.1 24
R4:
G 0/0/0 46.0.0.1 24
L0 192.168.4.1 24
R5:
G 0/0/0 56.0.0.1 24
L0 192.168.5.1 24
R6(ISP):
G 0/0/1 16.0.0.2 24
G 0/0/0 116.0.0.2 24
G 4/0/2 26.0.0.2 24
G 4/0/1 36.0.0.2 24
G 4/0/0 46.0.0.2 24
G 0/0/2 56.0.0.2 24
需求2:
R1/R4/R5为全连的MGRE结构
在R1上:
[r1]int t 0/0/1 #创建虚拟隧道
[r1-Tunnel0/0/1]ip address 192.168.6.1 24
[r1-Tunnel0/0/1]tunnel-protocol gre p2mp #选择协议类型
[r1-Tunnel0/0/1]source 116.0.0.1 #写源ip(固定)
Jul 13 2022 10:01:55-08:00 r1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface Tunnel0/0/1 has entered the UP state.
[r1-Tunnel0/0/1]nhrp network-id 200
[r1-Tunnel0/0/1]nhrp entry multicast dynamic
[r1-Tunnel0/0/1]nhrp entry 192.168.6.2 46.0.0.1 register #目的ip(实际和虚拟)
[r1-Tunnel0/0/1]nhrp entry 192.168.6.3 56.0.0.1 register
在R4上:
(同理R1)
[r4]int t 0/0/0
[r4-Tunnel0/0/0]ip address 192.168.6.2 24
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp
[r4-Tunnel0/0/0]source 46.0.0.1
Jul 13 2022 10:04:20-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r4-Tunnel0/0/0]nhrp network-id 200
[r4-Tunnel0/0/0]nhrp entry multicast dynamic
[r4-Tunnel0/0/0]nhrp entry 192.168.6.1 116.0.0.1 register
Info: This peer protocol address conflicts with hub register peer protocol addre
ss.
[r4-Tunnel0/0/0]nhrp entry 192.168.6.3 56.0.0.1 register
在R5上:
[r5]int t 0/0/0
[r5-Tunnel0/0/0]ip address 192.168.6.3 24
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source 56.0.0.1
Jul 13 2022 10:05:22-08:00 r5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r5-Tunnel0/0/0]nhrp network-id 200
[r5-Tunnel0/0/0]nhrp entry multicast dynamic
[r5-Tunnel0/0/0]nhrp entry 192.168.6.1 116.0.0.1 register
Info: This peer protocol address conflicts with hub register peer protocol addre
ss.
[r5-Tunnel0/0/0]nhrp entry 192.168.6.2 46.0.0.1 register
查看配置(因为都是“中心站点”,所以在R1/R4/R5上查看均可):
[r5-Tunnel0/0/0]display nhrp peer al
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
192.168.6.1 32 116.0.0.1 192.168.6.1 dynamic route tunnel
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:02:48
Expire time : 01:57:12
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
192.168.6.2 32 46.0.0.1 192.168.6.2 dynamic route tunnel
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:00:47
Expire time : 01:59:13
Number of nhrp peers: 2
R1/R2/R3为星型拓扑,R1为中心站点
在R1上
[r1]int t 0/0/0 #创建虚拟隧道
[r1-Tunnel0/0/0]ip address 192.168.7.1 24 #配置ip
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]source 16.0.0.1 #源ip
Jul 13 2022 09:53:09-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r1-Tunnel0/0/0]nhrp network-id 100
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
在R2上:
[r2]int t 0/0/0
[r2-Tunnel0/0/0]ip address 192.168.7.2 24 #创建虚拟隧道并配置ip
[r2-Tunnel0/0/0]tunnel-protocol gre p2mp #选择网络类型
[r2-Tunnel0/0/0]source g 0/0/0
Jul 13 2022 09:56:01-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r2-Tunnel0/0/0]nhrp network-id 100
[r2-Tunnel0/0/0]nhrp entry 192.168.7.1 16.0.0.1 register #目的ip(实际和虚拟)
在R3上:
(同理R2)
[r3]int t 0/0/0
[r3-Tunnel0/0/0]ip address 192.168.7.3 24
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp
[r3-Tunnel0/0/0]source g 0/0/0
Jul 13 2022 09:57:38-08:00 r3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/0 has entered the UP state.
[r3-Tunnel0/0/0]nhrp network-id 100
[r3-Tunnel0/0/0]nhrp entry 192.168.7.1 16.0.0.1 register
在R1上查看:
[r1-Tunnel0/0/0]display nhrp peer all
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
192.168.7.2 32 26.0.0.1 192.168.7.2 dynamic route tunnel
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:00:23
Expire time : 01:59:37
-------------------------------------------------------------------------------
Protocol-addr Mask NBMA-addr NextHop-addr Type Flag
-------------------------------------------------------------------------------
192.168.7.3 32 36.0.0.1 192.168.7.3 dynamic route tunnel
-------------------------------------------------------------------------------
Tunnel interface: Tunnel0/0/0
Created time : 00:00:18
Expire time : 01:59:42
Number of nhrp peers: 2
[r1-Tunnel0/0/0]
需求3:
所有私有网络可以互相通讯,私有网段使用OSPF完成
在R1上:
[r1]ospf 1 router-id 1.1.1.1 #配置ospf
[r1-ospf-1]area 0 #创建区域
[r1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 #宣告直连网段
[r1-ospf-1-area-0.0.0.0]network 192.168.6.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]q
[r1-ospf-1]q
[r1]int t 0/0/0
[r1-Tunnel0/0/0]ospf network-type p2mp #R1/R2/R3星型网络拓扑隧道网络类型:p2mp(中心站点)
[r1-Tunnel0/0/1]ospf network-type broadcast # R1/R4/R5 MGRE 网络类型:广播
在R2上:
(R3同理)
[r2]ospf 1 router-id 2.2.2.2
Info: The configuration succeeded. You need to restart the OSPF process to valid
ate the new router ID.
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255
[r2-Tunnel0/0/0]ospf network-type p2mp
[r2-Tunnel0/0/0]
[r2]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 7 Routes : 7
OSPF routing table status : <Active>
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.1/32 OSPF 10 1562 D 192.168.7.1 Tunnel0/0/0
192.168.3.1/32 OSPF 10 3124 D 192.168.7.1 Tunnel0/0/0
192.168.4.1/32 OSPF 10 3124 D 192.168.7.1 Tunnel0/0/0
192.168.5.1/32 OSPF 10 3124 D 192.168.7.1 Tunnel0/0/0
192.168.6.0/24 OSPF 10 3124 D 192.168.7.1 Tunnel0/0/0
192.168.7.1/32 OSPF 10 1562 D 192.168.7.1 Tunnel0/0/0
192.168.7.3/32 OSPF 10 3124 D 192.168.7.1 Tunnel0/0/0
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
在R4上:
(R5同理)
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0]network 192.168.6.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0]
[r4-Tunnel0/0/0]ospf network-type broadcast
[r4]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 7 Routes : 7
OSPF routing table status : <Active>
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.1/32 OSPF 10 1562 D 192.168.6.1 Tunnel0/0/0
192.168.2.1/32 OSPF 10 3124 D 192.168.6.1 Tunnel0/0/0
192.168.3.1/32 OSPF 10 3124 D 192.168.6.1 Tunnel0/0/0
192.168.5.1/32 OSPF 10 1562 D 192.168.6.3 Tunnel0/0/0
192.168.7.1/32 OSPF 10 1562 D 192.168.6.1 Tunnel0/0/0
192.168.7.2/32 OSPF 10 3124 D 192.168.6.1 Tunnel0/0/0
192.168.7.3/32 OSPF 10 3124 D 192.168.6.1 Tunnel0/0/0
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0