一、拓撲圖:
二、配置及說明:
1、配置三台路由器的IP位址。并且在R1和R3配置預設路由,確定廣域網鍊路能夠通信:
R1(config-line)#int s1/1 R1(config-if)#no sh R1(config-if)#ip add 202.101.172.37 255.255.255.252 R1(config-if)#int lo0 R1(config-if)#ip add 172.16.1.1 255.255.255.0 R1(config-if)#ip add 172.16.2.1 255.255.255.0 se R1(config-if)#exit R1(config)#ip route 0.0.0.0 0.0.0.0 202.101.172.38 (配置一條預設路由) R3(config-line)#int s1/0 R3(config-if)#no sh R3(config-if)#ip add 218.108.248.202 255.255.255.252 R3(config-if)#int lo0 R3(config-if)#ip add 192.168.1.1 255.255.255.0 R3(config-if)#ip add 192.168.2.1 255.255.255.0 se R3(config-if)#exit R3(config)#ip route 0.0.0.0 0.0.0.0 218.108.248.201 |
2、配置完之後,在R1 能夠ping 通R3的WAN口:
R1(config)#do ping 218.108.248.202 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 218.108.248.202, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 12/27/64 ms |
3、由于R2中沒有到達私有網絡的路由,在R1或R3都不能ping 通各自的回環接口IP:
R1(config)#do ping 192.168.1.1 Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: U.U.U Success rate is 0 percent (0/5) R1(config)# |
4、滿足條件之後,下面分别在R1和R3上通過GRE隧道技術把路由打通:
R1(config)#interface tunnel 0 (啟用GRE隧道) R1(config-if)#ip add 10.1.1.1 255.255.255.0 (為隧道配置IP位址) R1(config-if)#tunnel source serial1/1(配置隧道的本地源端口) R1(config-if)#tunnel destination 218.108.248.202 (配置隧道的目标出口,目的IP的可達性,是通過之前配置的本地預設路由保證的) R3(config)#int tunnel 0 R3(config-if)#ip add 10.1.1.2 255.255.255.0 R3(config-if)#tunnel source 218.108.248.202 (也可以指定隧道本地源IP) R3(config-if)#tunnel destination 202.101.172.37 |
5、R3配置完之後,馬上就出來提示資訊:
R3(config-if)# *Mar 1 01:06:52.095: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel0,changed state to up |
6、在R1上檢視一下隧道接口資訊:
R1#sh interfaces tunnel0 Tunnel0 is up, line protocol is up (狀态為UP) Hardware is Tunnel (基于隧道的接口) Internet address is 10.1.1.1/24 MTU 1514 bytes, BW 9 Kbit, DLY 500000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation TUNNEL, loopback not set (在原始的資料包上再封裝了一個GRE報頭) Keepalive not set Tunnel source 202.101.172.37 (Serial1/1), destination 218.108.248.202 Tunnel protocol/transport GRE/IP (隧道協定為GRE) Key disabled, sequencing disabled Checksumming of packets disabled Tunnel TTL 255 ……………… |
7、檢視一下R1的路由表:
R1#sh ip route ………… Gateway of last resort is 202.101.172.38 to network 0.0.0.0 202.101.172.0/30 is subnetted, 1 subnets C 202.101.172.36 is directly connected, Serial1/1 172.16.0.0/24 is subnetted, 2 subnets C 172.16.1.0 is directly connected, Loopback0 C 172.16.2.0 is directly connected, Loopback0 10.0.0.0/24 is subnetted, 1 subnets C 10.1.1.0 is directly connected, Tunnel0 (顯示隧道接口為直連路由) S* 0.0.0.0/0 [1/0] via 202.101.172.38 (之前配置的預設路由) |
8、在R1上能夠ping 通隧道位址:
R1#ping 10.1.1.2 Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds: Success rate is 100 percent (5/5), round-trip min/avg/max = 12/34/68 ms R1# |
9、為了使R1和R3的loopback 位址能夠通信,我們在R1和R3分别配置靜态路由,下一跳指向隧道接口:
R1(config)#ip route 192.168.0.0 255.255.0.0 tunnel 0 (下一跳可以指定隧道接口) R3(config)#ip route 172.16.0.0 255.255.0.0 10.1.1.1 (也可以指定隧道接口對端的IP) |
10、在R1或R3再次ping ,檢查是否能ping 通對方私有網絡回環接口IP位址:
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/38/108 ms R1(config)#do ping 192.168.2.1 Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds: Success rate is 100 percent (5/5), round-trip min/avg/max = 8/36/84 ms |
11、當然我們還可以檢視一下tunnl 0的統計資料:
R1#sh interface tunnel 0 stats Tunnel0 Switching path Pkts In Chars In Pkts Out Chars Out Processor 30 3720 30 3720 Route cache 0 0 0 0 Total 30 3720 30 3720 |
注意:在配置隧道的時候一定要注意隧道的本地源端口和隧道的目的端口的路由可達性。