<a target="_blank" href="http://blog.51cto.com/attachment/201212/154430843.jpg"></a>
GRE實驗
說明:我們模拟内外網環境,實作内網和内網間通過GRE隧道來實作通訊.
R0:
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa0/1
Router(config-if)#no shu
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
Router(config-if)#ip add 100.100.100.2 255.255.255.0
Router(config-if)#int fa0/0
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
Router(config-if)#ip add 200.200.200.2 255.255.255.0
R1:
Router>en
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#ip add 100.100.100.1 255.255.255.0
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#exi
Router(config)#ip ro
Router(config)#ip route 0.0.0.0 0.0.0.0 100.100.100.2
R3:
Router(config)#int fa0/0
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#ip add 192.168.1.2 255.255.255.0
Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1
R2:
Router(config-if)#ip add 200.200.200.1 255.255.255.0
Router(config-if)#int fa0/1
Router(config-if)#ip add 10.10.10.1 255.255.255.0
Router(config)#ip route 0.0.0.0 0.0.0.0 200.200.200.2
R4:
Router(config-if)#ip add 10.10.10.2 255.255.255.0
Router(config)#ip rou
Router(config)#ip route 0.0.0.0 0.0.0.0 10.10.10.1
測試連通性:
Router#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms
Router#ping 100.100.100.1
Sending 5, 100-byte ICMP Echos to 100.100.100.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/0 ms
Router#ping 100.100.100.2
Sending 5, 100-byte ICMP Echos to 100.100.100.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Router# \\隻能PING通預設下一跳
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
Router#ping 192.168.1.2
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/1/6 ms
Router#ping 200.200.200.2
Sending 5, 100-byte ICMP Echos to 200.200.200.2, timeout is 2 seconds:
Router#ping 200.200.200.1
Sending 5, 100-byte ICMP Echos to 200.200.200.1, timeout is 2 seconds:
Router#ping 10.10.10.1
Sending 5, 100-byte ICMP Echos to 10.10.10.1, timeout is 2 seconds:
U.U.U
Router#\\可以ping 通RO R2 R3
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router# \\可以PING通 R0 R1 R4
Success rate is 0 percent (0/5) \\可以PING通預設下一跳
Router>ping 100.100.100.1
Router>ping 200.200.200.1
Router>ping 192.168.1.1
Router>ping 10.10.10.1
Router>
\\可以PING通 R1的fa0/1 R2的fa0/0,到這一步,通過ping測試,我們已經模拟出了内外網環境,
R0 R1的fa0/1 R2的fa0/0,就是模拟的外網環境. R3和R1的fa0/0是個内網環境,R4和R2的fa0/1
是個内網環境.
建立通道:
Router(config)#int tunnel 1
%LINK-5-CHANGED: Interface Tunnel1, changed state to up
Router(config-if)#ip add 1.1.1.1 255.255.255.0
Router(config-if)#tn
Router(config-if)#tun
Router(config-if)#tunnel so
Router(config-if)#tunnel source fa0/1 \\注意PT的因素,源位址隻能定義為端口
Router(config-if)#tunnel de
Router(config-if)#tunnel destination 200.200.200.1
%LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel1, changed state to up
Router(config)#int tun
Router(config)#int tunnel 2
%LINK-5-CHANGED: Interface Tunnel2, changed state to up
Router(config-if)#ip add 1.1.1.2 255.255.255.0
Router(config-if)#tunnel source fa0/0
Router(config-if)#tunnel destination 100.100.100.1
%LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel2, changed state to up
測試通道連通:
Router#ping 1.1.1.1
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Router#ping 1.1.1.2
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
\\此步測試說明通道已經建立并且實作了連通
測試R3是否可以和R2,R4通訊?
Router>ping 10.10.10.2
Sending 5, 100-byte ICMP Echos to 10.10.10.2, timeout is 2 seconds:
\\再未使用通道前R3無法和R2 R4連通
定義感興趣流量
Router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 \\注意必須寫預設這一條.
Router(config)#ip route 192.168.1.0 255.255.255.0 1.1.1.2
Router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.1
Router(config)#ip route 10.10.10.0 255.255.255.0 1.1.1.1
測試再測試R3,R4連通性
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/3/14 ms
Router>tra
Router>traceroute 10.10.10.2
Tracing the route to 10.10.10.2
1 192.168.1.1 1 msec 0 msec 0 msec
2 1.1.1.2 0 msec 0 msec 0 msec \\看路由走的通道
3 10.10.10.2 0 msec 0 msec 11 msec
Router>ping 192.168.1.2
Router>traceroute 192.168.1.2
Tracing the route to 192.168.1.2
1 10.10.10.1 1 msec 0 msec 0 msec
2 1.1.1.1 0 msec 0 msec 0 msec \\看路由走的通道
3 192.168.1.2 0 msec 1 msec 12 msec
\\ 到這裡我們已經完成了此實驗.
本文轉自 am2012 51CTO部落格,原文連結:http://blog.51cto.com/goome/1078340