一、實驗拓撲:
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsISPrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdsATOfd3bkFGazxCMx8VesATMfhHLlN3XnxCMwEzX0xiRGZkRGZ0Xy9GbvNGLpZTY1EmMZVDUSFTU4VFRR9Fd4VGdsYTMfVmepNHLrJXYtJXZ0F2dvwVZnFWbp1zczV2YvJHctM3cv1Ce-cmbw5SN5M2M3UWO2M2M5gDN3ETOmJ2MzADMxgjN3EjNygTZi9CX3AzLcdDM4EDMy8CXn9Gbi9CXzV2Zh1WavwVbvNmLvR3YxUjLxM3Lc9CX6MHc0RHaiojIsJye.png)
二、指令部署:
1、R1和R3部署隧道:分别給R1、R3上隧道配位址、設定Tunnel的源位址、目的位址、模式、靜态路由
R3(config)#interface tunnel 3
R3(config-if)#ip add 31.1.1.3 255.255.255.0
R3(config-if)#tunnel source 3.3.3.3 可以是環回口位址:
R3(config-if)#tunnel destination 1.1.1.1
R3(config-if)#tunnel mode gre ip
R3#show run int tunnel 3 //檢視tunnel的配置
R3#ping 1.1.1.1 source 3.3.3.3 //tunnel的源目位址是否可以ping通
R3(config)#ip route 1.1.1.1 255.255.255.255 13.1.1.1
同理:R1部署Tunnel
R1(config)#interface tunnel 1
R1(config-if)#ip add 31.1.1.1 255.255.255.0
R1(config-if)#tunnel source 1.1.1.1
R1(config-if)#tunnel destination 3.3.3.3
R1(config-if)#tunnel mode gre ip
R1(config)#ip route 3.3.3.3 255.255.255.255 13.1.1.3
2、将Tunnel網段位址到Area 0
R3(config)#router ospf 110
R3(config-router)#network 31.1.1.0 0.0.0.255 area 0
R1(config)#router ospf 110
R1(config-router)#network 31.1.1.0 0.0.0.255 area 0
三、驗證:
1、配置驗證:
①檢視Tunnel配置
R3#show run int tunnel 3
interface Tunnel3
ip address 31.1.1.3 255.255.255.0
tunnel source 3.3.3.3
tunnel destination 1.1.1.1
②Tunnel的源目是否可以Ping通
R3#ping 1.1.1.1 source 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 3.3.3.3
!!!!!
③部署靜态路由到1.1.1.1,因為不允許将Tunnel的IP位址和源目同時宣告進OSPF,否則将會是Tunnel一會起來,一會挂掉。
R3#show ip route
1.0.0.0/32 is subnetted, 1 subnets
S 1.1.1.1 [1/0] via 13.1.1.1
2、部署完成後,檢視R5否有對方路由條目:
R5#show ip route ospf
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/11114] via 35.1.1.3, 00:00:34, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/11115] via 35.1.1.3, 00:00:34, FastEthernet0/0
24.0.0.0/24 is subnetted, 1 subnets
O IA 24.1.1.0 [110/11114] via 35.1.1.3, 00:00:34, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.1.1.0 [110/11113] via 35.1.1.3, 00:00:34, FastEthernet0/0
13.0.0.0/24 is subnetted, 1 subnets
O IA 13.1.1.0 [110/2] via 35.1.1.3, 00:05:20, FastEthernet0/0
31.0.0.0/24 is subnetted, 1 subnets
O IA 31.1.1.0 [110/11112] via 35.1.1.3, 00:05:20, FastEthernet0/0
R2#show ip route ospf
35.0.0.0/24 is subnetted, 1 subnets
O IA 35.1.1.0 [110/11113] via 12.1.1.1, 00:02:26, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/2] via 24.1.1.4, 00:39:03, FastEthernet1/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/11114] via 12.1.1.1, 00:02:26, FastEthernet0/0
13.0.0.0/24 is subnetted, 1 subnets
O IA 13.1.1.0 [110/2] via 12.1.1.1, 00:02:26, FastEthernet0/0
31.0.0.0/24 is subnetted, 1 subnets
O 31.1.1.0 [110/11112] via 12.1.1.1, 00:02:26, FastEthernet0/0
R5#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
轉載于:https://blog.51cto.com/13856092/2137521