第一步:配置基本
直连路由信息见图
第二步:为了使R1和R3能连通互联网
R1(config)#ip route 0.0.0.0 0.0.0.0 f0/0
R3(config)#ip route 0.0.0.0 0.0.0.0 f0/1
第三步:配置GRE隧道
R1(config)#interface tunnel 1
R1(config-if)#tu so f0/0
R1(config-if)#tu de 23.0.0.3
R1(config-if)#ip add 10.0.0.1 255.255.255.0
*May 13 16:13:30.191: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel1, changed state to up
R3(config)#interface tunnel 1
R3(config-if)#ip add 10.0.0.2 255.255.255.0
R3(config-if)#tu so f0/1
R3(config-if)#tu de 12.0.0.1
测试隧道
R1#ping 10.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/69/144 ms
第四步:配置路由协议,这样R1和R3上其它路由能通过协议建立关系
R1(config)#router ei 1
R1(config-router)#no au
R1(config-router)#net 10.0.0.0
R1(config-router)#net 1.1.1.1
R1(config-router)#net 192.168.1.1
R3(config)#router ei 1
R3(config-router)#no au
R3(config-router)#net 10.0.0.0
R3(config-router)#net 3.3.3.3
R1#traceroute 3.3.3.3 so 1.1.1.1
Type escape sequence to abort.
Tracing the route to 3.3.3.3
1 10.0.0.2 116 msec * 64 msec
//这里能通了,但是pc不能上网,我们配置PAT
第五步:配置PAT
R1(config)#access-list 100 permit ip 192.168.1.0 0.0.0.255 any
R1(config)#int f0/0
R1(config-if)#ip nat ou
R1(config-if)#int f0/1
R1(config-if)#ip nat in
R1(config)#ip nat inside source list 100 interface f0/0
第六步:测试,我们从pc上ping 外网,比如说2.2.2.2 和3.3.3.3
pc#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:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/49/72 ms
pc#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/49/72 ms
R1#sh ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp 12.0.0.1:2 192.168.1.2:2 2.2.2.2:2 2.2.2.2:2
//我们分别ping了2.2.2.2和3.3.3.3,但只有2.2.2.2转换了,因为3.3.3.3走的是隧道
注意,我们不能将PAT转换的outside用到int tunnel接口上,因为tunnel上的地址为私有的,这样PAT转换将没有意义