静态NAT转换
假设某机构的路由器R2, s0/1 口 为外网口。那么此时,内网地址也就是Inside local IP address 这里为192.168.0.1 Inside global IP address 这里为 202.106.0.1,我们首先在3太路由器上配置3条默认路由,保证三台可以通讯。
然后我们在 R2上配置.
- Ip nat inside sourc static 192.168.0.1 202.106.0.1
-
- Int e0/0
-
- Ip nat inside
-
- Int s0/1
-
- Ip nat outside
此时,我们从R1 ping 200.200.3.3 在R2上show ip nat trans看到有什么效果:
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="67" alt="浅析NAT应用" width="759" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000310.JPG" />
此时,我们看到, 源为192.168.0.1 经过R2之后 被翻译成了 202.106.0.1 这个地址。
我们在R3上 trace 192.168.0.1 ,然后会看到什么效果呢。
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="141" alt="浅析NAT应用" width="659" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000311.JPG" />
由此看来,192.168.0.1 已经杯202.106.0.1 代替了。
动态NAT转换
在R2上配置
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="91" alt="浅析NAT应用" width="615" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000312.JPG" />
配完之后我们在 R1上ping 202.106.0.3,同时我们在R2上show ip nat translation>
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="67" alt="浅析NAT应用" width="780" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000313.JPG" />
此时,我们看到,同样192.168.0.1 被转换成了202.106.0.1,那么我们用R2的 e1/0口 ping R3的lo0口会有什么现象呢:
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="96" alt="浅析NAT应用" width="787" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000314.JPG" />
<可见这时 192.168.0.2 被翻译成了另外一个地址。假设说我们没有那么多的公网ip可以用我们如何去做呢,这就是我们下面需要做得试验,pat(port address translation)我们在 R2上配置:
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="154" alt="浅析NAT应用" width="605" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000315.JPG" />
注意其中的 overload 字段, 此字段的意思是我们启动了地址复用的技术,也就是说我们可以将多个内部ip用202.106.0.1 这个ip+不同的端口号来代替,这样的话大大节省了ip地址的消耗。我们 在R1上ping 200.200.3.3 同时在R2上看效果:
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="59" alt="浅析NAT应用" width="776" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000316.JPG" />
可以看到此时被翻译之后的端口号为14我们再以R2的以太口做源ping200.200.3.3
498)this.width=498;'' onmousewheel = ''javascript:return big(this)'' height="60" alt="浅析NAT应用" width="776" border="0" src="http://images.51cto.com/files/uploadimg/20110415/1000317.JPG" />
此时我们看到 被翻译之后的端口号为3,这说明了地址复 |