<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