NAT

---------------------------------------------------------
配置R1接口和默认路由
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.1.1.2 24
[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet0/0/2]ip address 192.168.11.254 24
添加默认路由,下一跳指向10.1.1.1
[R1]ip route-static 0.0.0.0 0 10.1.1.1
配置外网R2路由器
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip add 10.1.1.1 24
配置本地环回接口,模拟互联网站
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 8.8.8.8 32
上面配置不变,以下各需求下都用此部分配置
-----------------------------------------------------
一,配置静态NAT
配置静态NAT,做一对一的地址转换。假设分给内网两个电脑两个公网ip地址10.1.1.3和10.1.1.4用来上网。
在R1出口GE0/0/0接口上配置静态NAT,与内网电脑一一对应。
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]nat static global 10.1.1.3 inside 192.168.11.3 netmask 255.255.255.255
[R1-GigabitEthernet0/0/1]nat static global 10.1.1.4 inside 192.168.11.4 netmask 255.255.255.255
---------------------------------------------------------------------------
给PC配置ip,分别去访问互联网8.8.8.8,都能成功访问


====================================================================
二,使用公网地址池,为内网用户做NAT转换。(no-pat)

如上图不变,假设分给公司A部分10.1.1.10-10.1.1.20为内网192.168.11.0/24的员工上网所用。
在R1上配置地址池
[R1]nat address-group 1 10.1.1.10 10.1.1.20
创建acl,匹配需要上网的内网段
[R1]acl 2000
[R1-acl-basic-2000]rule permit source 192.168.11.0 0.0.0.255
在路由出口引用acl 2000,使匹配的网段中的地址可以使用地址池中地址进行NAT转换。
[R1-GigabitEthernet0/0/1]nat outbound 2000 address-group 1 no-pat

在路由出口GE0/0/1上抓包,可看到内网地址已被转换为10.1.1.10发出。

==================================================================
三,使用Easy-IP配置NAT实现上网(端口转换)
如图,拓扑和网段不变,假设公司人员越来越多,公网地址紧张,于是使用Easy IP 的方式满足让B部门上网的需求。

配置acl 2001匹配内网需要上网的网段
[R1]acl 2001
[R1-acl-basic-2001]rule permit source 192.168.11.0 0.0.0.255
到路由出口GE0/0/1口调用acl 2001
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]nat outbound 2001
用pc去ping 8.8.8.8 ,查看源地址已经是以接口地址发出了。

==================================================================
四,配置使用公网地址池的NAT端口地址转换。
创建可用的公网地址池
[R1]nat address-group 2 10.1.1.30 10.1.1.40
配置匹配的内网段
[R1]acl 2002 rule
[R1-acl-basic-2002]rule permit source 192.168.11.0 0.0.0.255
把acl绑定到路由器出口
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]nat outbound 2002 address-group 2
关键词:ip/NAPT代理上网(ip网络代理)