GRE隧道的配置
1,構建如圖所示拓撲圖;
2,分別爲5臺路由器配置IP地址,將R2,R3模擬爲外網與內網的邊界路由器,R1------R2屬於分支1;R4----R5屬於分支2。在分支1和分支2內採用OSPF協議,在外網採用EIGRP協議。
3,對R2開啓GPE隧道,配置如下
R2#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface tunnel 0
R2(config-if)#tunnel source 23.23.23.1
R2(config-if)#tunnel destination 34.34.34.2
R2(config-if)#ip address 24.24.24.1 255.255.255.0
R2(config-if)#exit
在R2上通告新的OSPF網段
R2(config)#router ospf 10
R2(config-router)#network 24.24.24.0 0.0.0.255 area 0
4,對R4開啓GPE隧道,配置如下
R4(config)#interface tunnel 0
R4(config-if)#tunnel source 34.34.34.2 /*源地址目的地址對換*/
R4(config-if)#tunnel destination 23.23.23.1
R4(config-if)#ip address 24.24.24.2 255.255.255.0
R4(config-if)#exit
在R4上通告新的OSPF網段
R4(config)#router ospf 10
R4(config-router)#network 24.24.24.0 0.0.0.255 area 0
5,配合wireshark轉包軟件來說明數據包從分支1到分支2整個過程中協議的封裝轉換
通過測試,R1能順利通過GRE隧道到達分支2。
由此可見,IP數據包在邊界路由器進行了再次封裝,改變了其源IP地址和目的IP地址。