ip nat inside source
Translates the source of IP packets that are traveling inside to outside.
功能1:将从内到外的IP包的源地址进行转换(将内部局部地址转换为内部全局地址)
Translates the destination of the IP packets that are traveling outside to inside.
功能2:将从外回包到内的IP包的目的地址进行转换(将内部全局地址转换为内部局部地址)

ip nat outside source
Translates the source of the IP packets that are traveling outside to inside.
功能1:将从外到内的IP包的源地址进行转换(将外部全局地址转换为外部局部地址)
Translates the destination of the IP packets that are traveling inside to outside.
功能2:将从内回包到外的IP包的目的地址进行转换(将外部局部地址转换为外部全局地址)

ip nat inside destination
Translates the destination of IP packets that are traveling inside to outside.
功能1:将从内到外的IP包的目的地址进行转换(将外部局部地址转换为外部全局地址)
Translates the source of the IP packets that are traveling outside to inside.
功能2:将从外回包到内的IP包源地址进行转换(将外部全局地址转换为外部局部地址)


ip nat outside destination
Translates the destination of the IP packets that are traveling outside to inside.
功能1:将从外到内的IP包的目的地址进行转换(将内部全局地址转换为内部局部地址)

Translates the source of the IP packets that are traveling inside to outside.
功能2:将从内回包到外的IP包目的地址进行转换(将内部局部地址转换为内部全局地址)
 
背景知识:
NAT 中的地址概念 :
本篇文章介绍一下网络地址翻译 (NAT) 中的四种地址概念: inside local address, inside global address, outside local address, outside global address.
说明:
本篇文章介绍一下网络地址翻译 (NAT) 中的四种地址概念: inside local address, inside global address, outside local address, outside global address.
从字面上看,地址可以被分成两类: inside( 内 ), outside( 外 ). 内和外是根据 NAT 功能定义的。具有 NAT 功能的设备像一个桥连接了内部网与外部网,连接内部的接口卡称为 ”inside”, 连接外部的接口卡称为 ”outside”. 即 inside 地址是给内网中的设备使用的, outside 地址是给外网中的设备使用的。
地址也可以被分成 local, global 两类。 Local 地址是内网上的设备所能看到和使用的地址; global 地址是外网设备所能看到和使用的地址。
 
我们看看这四种地址:
inside local address, 内网中设备所使用的 IP 地址,此地址通常是一个私有地址;
inside global address, 公用地址,通常是 ISP 所提供的,由内网设备与外网设备通信时所使用到;
outside local address, 外网中设备所使用的地址,这个地址是在面向内网设备时所使用的,它不一定是一个公网地址;
outside global address, 外网设备所使用的真正的地址;
从内网中设备上发出的 IP 包是以 ”inside local address” 作为源地址,以 ”outside local address” 作为目的地址。当数据包到达 NAT 设备的 ”inside” 接口后,地址分别被翻译成 ”inside global address” 和 ”outside global address” 并从 ”outside” 接口送出。
 
同样,从外网设备上发出的 IP 包以 ”outside global address” 作为源地址,以 ”inside global address” 作为目的地址。当数据包到达 NAT 设备的 ”outside” 接口后,地址分别被翻译成 ”outside local address” 和 ”inside local address” 并从 ”inside” 接口送出。
 

我们举个几个例子:
 

内网地址是 10.10.10.x 网段的地址,外网地址是 171.16.68.x 的地址。路由器行使 NAT 功能,它的 S0 口接内网, S1 口接外网。
 
内网的设备 10.10.10.1 需要和外网通信,它所使用的外网地址是 171.16.68.5; 换句话说,当路由器从外网收到一个去 171.16.68.5 的数据包时,它知道要数据包实际是要送给 10.10.10.1 的。我们看到,由于外网地址和内网地址没有冲突,因此对外网设备 171.16.68.1 来说,它的地址不需要再做翻译了,即 outside local address 等于 outside global address. 这种情况包括了大部分的 NAT 应用,即只翻译 inside 方地址,而不需要翻译 outside 地址。
 
NAT 设备中应该维护一张类似于下表的地址映射:

Inside Global
Inside Local
Outside Local
Outside Global
171.16.68.5
10.10.10.1
171.16.68.1
171.16.68.1
 

第二种情况是翻译外网机器的地址,这种方式并不常用,因为这样会导致私有地址路由泄漏到公网上。但这个例子可以加深对 NAT 的理解。
这里 NAT 设备对外网进来的包的源地址做翻译,翻译成与内网地址在同网段的地址。即外部机器 172.16.68.1 在内部机器看来是 10.10.10.5

Inside Global
Inside Local
Outside Local
Outside Global
10.10.10.1
10.10.10.1
10.10.10.5
171.16.68.1
 

最后一种可能是对内网机器和外网机器都要做地址翻译,此时通常两部分的地址有冲突或重叠。因此 NAT 设备对数据的源和目的都做了地址翻译。在这种情况下,双方看到的地址都不是对方的真实地址。

Inside Global
Inside Local
Outside Local
Outside Global
171.16.68.5
10.10.10.1
10.10.10.5
171.16.68.1
 

通过这三个例子,我们了解到 NAT 中的 ”local” 和 ”global” 的含义, Local 是对内网设备看到的,无论是 inside local 还是 outside local; global 是对外网设备看到的。针对不同的 NAT 配置, inside local address 和 outside local address 可能一样,也可能不一样。 global address 也是如此。