NAT配置思路:

1、配置内网和外网设备的IP地址

2、配置网关设备上的默认路由
     ip route 0.0.0.0 0.0.0.0 100.1.1.4 

3、配置 ISP 边的网络(内网启用IGP - RIP )
      ISP:
	     router rip 
		    version 2 
			no auto-summary
			network 200.1.1.0
			network 100.0.0.0
			passive-interface gi1/0
      R5:
	     router rip 
		    version 2
			no auto-summary
		    network 200.1.1.0
3、在网关设备上配置 NAT 边界
     interface fa0/0
	    ip nat inside 
     interface gi1/0
	    ip nat outside 
4、配置 NAT 转换条目
     ip nat inside source static 192.168.10.1  100.1.1.3
	 
5、验证、测试、保存
    show ip route 
	show ip nat translation
	debug ip nat 
	PC-1:
	   ping 200.1.1.5 

==============================================================

静态NAT:
   在这种类型的NAT中,私有地址与公有地址的对应关系是 1:1 , 不节省IP地址;
   
   
在动态NAT的一种类型中 ---- PNAT(port NAT) ,
   所形成的私有地址与公有地址的对应关系是:n:1 ,节省IP地址;
   本质是:
       使用同一个公网IP地址的,不同的,端口号,来对应内网不同的私有主机   

配置思路:
    1、确定 NAT 边界
	2、确定需要进行 NAT 转换的私有地址空间
	
	   工具
	      -匹配感兴趣的流量
		     内网中
			 所有
			 数据包源IP
			 为192.168.10.X 的
			 IP数据包
	
	    规则1:     192.168.10. 0  
	                 0 . 0 . 0.255	-->通配符	 
	                               //按照这个规则,可以抓住所有源IP地址
								     为 192.168.10.X 的所有数据包;
									 
		工具,称之为  ACL - access control list :访问控制列表	

            ACL:
                规则 - 匹配感兴趣流量的; 
                动作 - permit /  deny 
                事件 - 需要对“感兴趣流量”做的事情。			
									 
			access-list  1   permit  192.168.10.0 0.0.0.255 						 
		
	
	3、针对私有地址,配置对应的 NAT 转换条目
	
           GW(config)#  ip nat inside source  list 1  interface gi1/0 
	
	4、验证、测试、保存
	       show ip nat statistics  //查看 NAT 的简要配置信息; 
		   show ip access-list     // 查看配置好的 ACL ; 
		   show ip nat translation // 查看 NAT 的核心工作表 - NAT表
		   
		   GW#debug ip nat 
		   
		   PC-1/2:
		      ping 200.1.1.5
		   
================================================================

在边界网关上,如果事事了NAT ,那么:

      1、当流量从inside到outside时,先查路由表,再查NAT表;
	  
      2、当流量从outside到inside时,先查NAT表,再查路由表;	  


所以,我们可以在 outside 主动向 inside 发起流量,前提是我们得保证
边界网关上面是有 NAT 条目的,
当然该条目不能是由内网流量触发的,而应该是永久存在的静态NAT条目。

我们将这种配置称之为:NAT的高级应用。

代表1:
     端口映射
	 	 
	 GW(config)#ip nat inside source static tcp 192.168.10.1 23
	                                            100.1.1.3  123456

测试:
   1、首先配置好 PC-1 的远程访问密码;
   2、其次配置好 GW 的远程访问密码; 
   3、最后,在 R5 上进行测试:
         telnet 100.1.1.3 123456 

================================================================
华为NAT (分类与思科完全相同)
   静态NAT :私有地址与公有地址是 1:1 ,不节省IP地址;
   动态NAT :私有地址与公有地址是 多:1 , 节省IP地址;
       -普通“动态NAT”
	   -PAT/PNAT/NAPT/端口复用
	   
静态NAT配置: 
    1、启动NAT功能
	      #在任意端口上启用都可以
		    例如:
			    interface gi0/0/1
				   nat static enable -->启动静态NAT功能
	2、配置NAT转换条目(两种配置方式)
	      1# 可以在全局下配置
		     nat static global 100.1.1.3  inside 192.168.10.1
			 
		  2# 可以在接口下配置(必须是数据包的出端口)
		     nat static global 100.1.1.3  inside 192.168.10.1		     
	      
	3、验证、测试、保存
	      display nat static 
		   
		  <ISP>terminal monitor
		  <ISP>terminal debugging
		  <ISP>debugging ip icmp 
		  <GW>debugging nat all 

PNAT的配置:
    1、定义感兴趣的流量
	     acl 2000 
		   rule 5  permit 192.168.10.0  0.0.0.255
		   
	2、在流量的出端口配置NAT
	     interface gi0/0/1 
		   nat outbound 2000 -->在该端口上发送出去,并且被 ACL 2000
		                        匹配的流量,其中的源IP地址转换为该
								接口的IP地址;
	3、验证、测试、保存
          display nat outbound



华为端口映射:
 interface g 0/0/0 

       nat server protocol tcp global current-interface 80 inside 192.168.1.1 80  //外网通过tcp协议的80端口访问内网的80端口