NAT配置思路: 一、配置内网和外网设备的IP地址 二、配置网关设备上的默认路由 ip route 0.0.0.0 0.0.0.0 100.1.1.4 三、配置 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 三、在网关设备上配置 NAT 边界 interface fa0/0 ip nat inside interface gi1/0 ip nat outside 四、配置 NAT 转换条目 ip nat inside source static 192.168.10.1 100.1.1.3 五、验证、测试、保存 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地址的,不一样的,端口号,来对应内网不一样的私有主机 配置思路: 一、肯定 NAT 边界 二、肯定须要进行 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 三、针对私有地址,配置对应的 NAT 转换条目 GW(config)# ip nat inside source list 1 interface gi1/0 四、验证、测试、保存 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 ,那么: 一、当流量从inside到outside时,先查路由表,再查NAT表; 二、当流量从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 测试: 一、首先配置好 PC-1 的远程访问密码; 二、其次配置好 GW 的远程访问密码; 三、最后,在 R5 上进行测试: telnet 100.1.1.3 123456 ================================================================ 华为NAT (分类与思科彻底相同) 静态NAT :私有地址与公有地址是 1:1 ,不节省IP地址; 动态NAT :私有地址与公有地址是 多:1 , 节省IP地址; -普通“动态NAT” -PAT/PNAT/NAPT/端口复用 静态NAT配置: 一、启动NAT功能 #在任意端口上启用均可以 例如: interface gi0/0/1 nat static enable -->启动静态NAT功能 二、配置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 三、验证、测试、保存 display nat static <ISP>terminal monitor <ISP>terminal debugging <ISP>debugging ip icmp <GW>debugging nat all PNAT的配置: 一、定义感兴趣的流量 acl 2000 rule 5 permit 192.168.10.0 0.0.0.255 二、在流量的出端口配置NAT interface gi0/0/1 nat outbound 2000 -->在该端口上发送出去,而且被 ACL 2000 匹配的流量,其中的源IP地址转换为该 接口的IP地址; 三、验证、测试、保存 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端口