不相邻的设备之间建立OSPF协议
为了解决不相邻的设备之间建立OSPF协议,最典型的案例就是GRE隧道虚拟接口建立OSPF协议。以H3C交换机建立GRE隧道后配置OSPF协议:
(题外问题:两个分支核心交换如果有ipsec VPN某两个地址可达,则可以先建立GRE隧道,然后建立OSPF,理论可行,实际待测试。)
拓扑:
SWA----RTB----SWC
基础配置略
GRE隧道配置:
SWA配置:
[SWA]interface Tunnel 0 mode gre
[SWA-Tunnel0]source 113.113.113.113
[SWA-Tunnel0]destination 114.114.114.114
[SWA-Tunnel0]ip address 10.1.1.1 24
[SWA-Tunnel0]quit
SWC配置:
[SWC]interface Tunnel 0 mode gre
[SWC-Tunnel0]source 114.114.114.114
[SWC-Tunnel0]destination 113.113.113.113
[SWC-Tunnel0]ip address 10.1.1.2 24
#完成以上步骤gre接口地址互通
OSPF配置:
SWA配置:
[SWA]ospf 1 router-id 1.1.1.1
[SWA-ospf-1]area 0
[SWA-ospf-1-area-0.0.0.0]network 10.1.1.1 0.0.0.0 #0.0.0.0表示此接口启用OSPF协议。
[SWA-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[SWA-ospf-1-area-0.0.0.0]network 192.168.2.1 0.0.0.0
[SWA-ospf-1-area-0.0.0.0]quit
[SWA-ospf-1]quit
SWC配置:
[SWC]ospf 1 router-id 2.2.2.2
[SWC-ospf-1]area 0
[SWC-ospf-1-area-0.0.0.0]network 10.1.1.2 0.0.0.0
[SWC-ospf-1-area-0.0.0.0]network 172.16.1.1 0.0.0.0
[SWC-ospf-1-area-0.0.0.0]network 172.16.2.1 0.0.0.0
[SWC-ospf-1-area-0.0.0.0]quit
[SWC-ospf-1]quit
[SWA]display ospf peer
OSPF Process 1 with Router ID 1.1.1.1
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
2.2.2.2 10.1.1.2 1 36 Full/ - Tun0
[SWA]display ip routing-table protocol ospf
Summary count : 5
OSPF Routing table status : <Active>
Summary count : 2
Destination/Mask Proto Pre Cost NextHop Interface
172.16.1.1/32 O_INTRA 10 1562 10.1.1.2 Tun0
172.16.2.1/32 O_INTRA 10 1562 10.1.1.2 Tun0
OSPF Routing table status : <Inactive>
Summary count : 3
Destination/Mask Proto Pre Cost NextHop Interface
10.1.1.0/24 O_INTRA 10 1562 0.0.0.0 Tun0
192.168.1.1/32 O_INTRA 10 0 0.0.0.0 Loop0
192.168.2.1/32 O_INTRA 10 0 0.0.0.0 Loop1
[SWA]ping -a 192.168.1.1 172.16.1.1
Ping 172.16.1.1 (172.16.1.1) from 192.168.1.1: 56 data bytes, press CTRL_C to break
56 bytes from 172.16.1.1: icmp_seq=0 ttl=255 time=15.928 ms
56 bytes from 172.16.1.1: icmp_seq=1 ttl=255 time=13.881 ms
56 bytes from 172.16.1.1: icmp_seq=2 ttl=255 time=14.061 ms
56 bytes from 172.16.1.1: icmp_seq=3 ttl=255 time=14.007 ms
56 bytes from 172.16.1.1: icmp_seq=4 ttl=255 time=17.359 ms
--- Ping statistics for 172.16.1.1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 13.881/15.047/17.359/1.381 ms
[SWA]%Jan 4 15:06:41:112 2020 SWA PING/6/PING_STATISTICS: Ping statistics for 172.16.1.1: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 13.881/15.047/17.359/1.381 ms.