NAT(Network Address Translation)
当今的互联网是由一个个小的自治系统组成,一个家庭,一个企业就是一个小的自治系统
自治系统内部有着众多的设备需要IP地址联网,每个地址都需要去IANA申请明显做不到,所以就会使用私有IP地址进行分配
私有IP地址无法做到互联网通信,在内网之中就需要一个默认网关来代替大家请求互联网数据
NAT网络地址转换技术能够将数据包中的IP地址进行转换
静态NAT
步骤
地址配置
R1(config)#int e0/0R1(config-if)#ip add 192.168.13.1 255.255.255.0R1(config-if)#no shR1(config-if)#int e0/1*Feb 1 07:53:24.935: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up*Feb 1 07:53:25.946: %LINEPROTO-5-UPDOWN: Line protocol on InterfaceEthernet0/0, changed state to upR1(config-if)#int e0/1R1(config-if)#ip add 100.12.12.1 255.255.255.0R1(config-if)#no shR1(config-if)#*Feb 1 07:53:40.608: %LINK-3-UPDOWN: Interface Ethernet0/1, changed state to up*Feb 1 07:53:41.615: %LINEPROTO-5-UPDOWN: Line protocol on InterfaceEthernet0/1, changed state to upR1(config-if)#R2(config)#int e0/0R2(config-if)#ip add 100.12.12.2 255.255.255.0R2(config-if)#no shR2(config-if)#int lo0R2(config-if)#ip add 2.2.2.2 255.255.255.0R3(config)#int e0/0R3(config-if)#ip add 192.168.13.3 255.255.255.0R3(config-if)#no sh
在R1和R3上添加默认路由指向运营商 ```bash R1(config)#ip route 0.0.0.0 0.0.0.0 100.12.12.2
R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.13.1
- 在R1上做静态路由转换, 找运营商获得一个公网IP地址, 假设是 100.12.12.3 ,然后将其对应的分配给 192.168.13.3 ,那么R3在上网的时候就可以用公网IP地址对外了```bashR1(config)#int e0/0R1(config-if)#ip nat insideR1(config-if)#int e0/1R1(config-if)#ip nat outsideR1(config-if)#exitR1(config)#ip nat inside source static 192.168.13.3 100.12.12.3
- 验证R3是否能访问外网
R3#ping 2.2.2.2Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:.!!!!Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/2 ms

