目录
MGRE环境下的OSPF实验
实验图
基本思路
R1 0/0/0接口为16.0.0.1 / 24
0/0/1接口为161.0.0.1 / 24
环回地址:192.168.1.1 / 24
R2 0/0/0接口为26.0.0.1 / 24
回环地址为192.168.2.1 / 24
R3 0/0/0接口为36.0.0.1 / 24
回环地址为192.168.3.1 / 24
R4 0/0/0接口为46.0.0.1 / 24
回环地址为192.168.4.1 / 24
R5 0/0/0接口为56.0.0.1 / 24
回环地址为192.168.5.1 / 24
R6 0/0/0接口为16.0.0.2 / 24
0/0/1接口为161.0.0.2 / 24
2/0/0接口为26.0.0.2 / 24
3/0/0接口为36.0.0.2 / 24
4/0/0接口为46.0.0.2 / 24
0/0/2接口为56.0.0.2 / 24
基本配置
R1
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip add
[R1-GigabitEthernet0/0/0]ip address 16.0.0.1 24
Sep 23 2022 14:24:40-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add
[R1-GigabitEthernet0/0/1]ip address 161.0.0.1 24
Sep 23 2022 14:25:47-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]
[R1-GigabitEthernet0/0/1]
[R1-GigabitEthernet0/0/1]q
[R1]
[R1]int LoopBack 0
[R1-LoopBack0]ip add
[R1-LoopBack0]ip address 192.168.1.1 24
R2
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add
[R2-GigabitEthernet0/0/0]ip address 26.0.0.1 24
Sep 23 2022 14:26:36-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 loop 0
[R2-LoopBack0]ip add
[R2-LoopBack0]ip address 192.168.2.1 24
R3
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip add
[R3-GigabitEthernet0/0/0]ip address 36.0.0.1 24
Sep 23 2022 14:30:37-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 loop 0
[R3-LoopBack0]ip ad
[R3-LoopBack0]ip address 192.168.3.1 24
R4
[R4]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip add
[R4-GigabitEthernet0/0/0]ip address 46.0.0.1 24
Sep 23 2022 14:31:14-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 loop 0
[R4-LoopBack0]ip ad
[R4-LoopBack0]ip address 192.168.4.1 24
[R4-LoopBack0]
R5
[R5]int g 0/0/0
[R5-GigabitEthernet0/0/0]ip ad
[R5-GigabitEthernet0/0/0]ip address 56.0.0.1 24
Sep 23 2022 14:31:55-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 loop 0
[R5-LoopBack0]ip add
[R5-LoopBack0]ip address 192.168.5.1 24
[R5-LoopBack0]
R6
[R6]int g 0/0/0
[R6-GigabitEthernet0/0/0]ip ad
[R6-GigabitEthernet0/0/0]ip address 16.0.0.2 24
Sep 23 2022 14:33:46-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 g 0/0/1
[R6-GigabitEthernet0/0/1]ip add
[R6-GigabitEthernet0/0/1]ip address 161.0.0.2 24
[R6-GigabitEthernet0/0/1]
Sep 23 2022 14:33:58-08:00 R6 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R6-GigabitEthernet0/0/1]int g 2/0/0
[R6-GigabitEthernet2/0/0]ip add
[R6-GigabitEthernet2/0/0]ip address 26.0.0.2 24
[R6-GigabitEthernet2/0/0]
Sep 23 2022 14:34:16-08:00 R6 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet2/0/0 has entered the UP state.
[R6-GigabitEthernet2/0/0]int g 3/0/0
[R6-GigabitEthernet3/0/0]ip add
[R6-GigabitEthernet3/0/0]ip address 36.0.0.2 24
[R6-GigabitEthernet3/0/0]
Sep 23 2022 14:34:31-08:00 R6 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP
on the interface GigabitEthernet3/0/0 has entered the UP state.
[R6-GigabitEthernet3/0/0]int g 4/0/0
[R6-GigabitEthernet4/0/0]ip add
[R6-GigabitEthernet4/0/0]ip address 46.0.0.2 24
[R6-GigabitEthernet4/0/0]
Sep 23 2022 14:34:53-08:00 R6 %%01IFNET/4/LINK_STATE(l)[4]:The line protocol IP
on the interface GigabitEthernet4/0/0 has entered the UP state.
[R6-GigabitEthernet4/0/0]int g 0/0/2
[R6-GigabitEthernet0/0/2]ip add
[R6-GigabitEthernet0/0/2]ip address 56.0.0.2 24
[R6-GigabitEthernet0/0/2]
Sep 23 2022 14:35:03-08:00 R6 %%01IFNET/4/LINK_STATE(l)[5]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R6-GigabitEthernet0/0/2]
写路由缺省使得公网可以ping通
R1
[R1]ip route-static 0.0.0.0 0 16.0.0.2
[R1]ip ro
[R1]ip route-s
[R1]ip route-static 0.0.0.0 0 161.0.0.2
[R1]
R2
[R2]ip ro
[R2]ip route-s
[R2]ip route-static 0.0.0.0 0 26.0.0.2
[R2]
注意:R3,R4,R5配置相同
制定R1/2/3为星型拓扑结构
私有网段:7.0网段
R1
1.配置地址
[R1]int t 0/0/0
[R1-Tunnel0/0/0]ip add
[R1-Tunnel0/0/0]ip address 192.168.7.1 24
[R1-Tunnel0/0/0]
2.定义封装接口
[R1-Tunnel0/0/0]tu
[R1-Tunnel0/0/0]tunnel-protocol g
[R1-Tunnel0/0/0]tunnel-protocol gre p
[R1-Tunnel0/0/0]tunnel-protocol gre p2mp
[R1-Tunnel0/0/0]
3.定义封装内容
[R1-Tunnel0/0/0]so
[R1-Tunnel0/0/0]source ?
Ethernet Ethernet interface
GigabitEthernet GigabitEthernet interface
LoopBack LoopBack interface
NULL NULL interface
Tunnel Tunnel interface
X.X.X.X IP address
vpn-instance Specify the vpn instance of the source
[R1-Tunnel0/0/0]source 16.0.0.1
Sep 23 2022 14:50:18-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]
4.创建nhrp域
[R1-Tunnel0/0/0]nh
[R1-Tunnel0/0/0]nhrp ?
authentication Configure the authentication string for an interface using the
NHRP
entry NHRP mapping
network-id NHRP network id
redirect Configure Next Hop Resolution Protocol (NHRP) redirect
registration Register
shortcut Configure NHRP shortcut information
[R1-Tunnel0/0/0]nhrp net
[R1-Tunnel0/0/0]nhrp network-id 100
[R1-Tunnel0/0/0]
5.开启伪广播当做中心站点
[R1-Tunnel0/0/0]nhr
[R1-Tunnel0/0/0]nhrp en
[R1-Tunnel0/0/0]nhrp entry ?
IP_ADDR<X.X.X.X> IP address
holdtime NHRP entry holdtime
multicast IP multicast
[R1-Tunnel0/0/0]nhrp entry mu
[R1-Tunnel0/0/0]nhrp entry multicast dy
[R1-Tunnel0/0/0]nhrp entry multicast dynamic
[R1-Tunnel0/0/0]
R2
[R2]int t 0/0/0
[R2-Tunnel0/0/0]ip add
[R2-Tunnel0/0/0]ip address 192.168.7.2 24
[R2-Tunnel0/0/0]tu
[R2-Tunnel0/0/0]tunnel-protocol nh
[R2-Tunnel0/0/0]tunnel-protocol ?
gre Generic Routing Encapsulation
ipsec IPSEC Encapsulation
ipv4-ipv6 IP over IPv6 encapsulation
ipv6-ipv4 IPv6 over IP encapsulation
mpls MPLS Encapsulation
none Null Encapsulation
[R2-Tunnel0/0/0]tunnel-protocol gr
[R2-Tunnel0/0/0]tunnel-protocol gre p
[R2-Tunnel0/0/0]tunnel-protocol gre p2mp
[R2-Tunnel0/0/0]
配置初接口
[R2-Tunnel0/0/0]sou
[R2-Tunnel0/0/0]source ?
Ethernet Ethernet interface
GigabitEthernet GigabitEthernet interface
LoopBack LoopBack interface
NULL NULL interface
Tunnel Tunnel interface
X.X.X.X IP address
vpn-instance Specify the vpn instance of the source
[R2-Tunnel0/0/0]source g
[R2-Tunnel0/0/0]source GigabitEthernet 0/0/0
Sep 23 2022 14:53:44-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]
填写中心站点
[R2-Tunnel0/0/0]nhr
[R2-Tunnel0/0/0]nhrp en
[R2-Tunnel0/0/0]nhrp entry 192.168.7.1 16.0.0.1 re
[R2-Tunnel0/0/0]nhrp entry 192.168.7.1 16.0.0.1 register
[R2-Tunnel0/0/0]
[R2-Tunnel0/0/0]nhrp network-id 100
[R2-Tunnel0/0/0]
注意:R3与R2配置类似
测试
[R1]dis
[R1]display nhrp
[R1]display nhrp ?
peer Peer
statistics NHRP statistics information
[R1]display nhrp pee
[R1]display nhrp peer ?
IP_ADDR<X.X.X.X> IP address
all All
dynamic Allow NHRP to automatically add routers to the multicast
NHRP mappings
interface Interface information
static Static
[R1]display nhrp peer a
[R1]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:05:19
Expire time : 01:54:41
-------------------------------------------------------------------------------
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:59
Expire time : 01:59:01
Number of nhrp peers: 2
[R1]
说明中心到站点的MGRE环境配置完成
R1/4/5全连MGRE结构中心站点为R1
网段信息:为6.0网段
R1
[R1]int t 0/0/1
[R1-Tunnel0/0/1]ip add
[R1-Tunnel0/0/1]ip address 192.168.6.1 24
[R1-Tunnel0/0/1]
[R1-Tunnel0/0/1]tu
[R1-Tunnel0/0/1]tunnel-protocol gr
[R1-Tunnel0/0/1]tunnel-protocol gre p
[R1-Tunnel0/0/1]tunnel-protocol gre p2mp
[R1-Tunnel0/0/1]so
[R1-Tunnel0/0/1]source 161.0.0.1
Sep 23 2022 15:03:00-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Tunnel0/0/1 has entered the UP state.
[R1-Tunnel0/0/1]
[R1-Tunnel0/0/1]nhrp
[R1-Tunnel0/0/1]nhrp ?
authentication Configure the authentication string for an interface using the
NHRP
entry NHRP mapping
network-id NHRP network id
redirect Configure Next Hop Resolution Protocol (NHRP) redirect
registration Register
shortcut Configure NHRP shortcut information
[R1-Tunnel0/0/1]nhrp ne
[R1-Tunnel0/0/1]nhrp network-id 110
开启伪广播设置R1为中心站点
[R1-Tunnel0/0/1]nhr
[R1-Tunnel0/0/1]nhrp en
[R1-Tunnel0/0/1]nhrp entry m
[R1-Tunnel0/0/1]nhrp entry multicast dy
[R1-Tunnel0/0/1]nhrp entry multicast dynamic
[R1-Tunnel0/0/1]
注意:R4,R5配置与R1类似
私有网段使用OSPF配置
R1
[R1]ospf 1 r
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]are
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]net
[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]ne
[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]ne
[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]
R2
[R2]ospf ro
[R2]ospf router-id 2.2.
[R2]ospf router-id 2.2.2.2
[R2-ospf-1]a
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]net
[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]net
[R2-ospf-1-area-0.0.0.0]network 192.168.7.0 0.0.0.255
注意:R3/4/5/6都类似