NAT配置思路:网络
一、配置内网和外网设备的IP地址tcp
二、配置网关设备上的默认路由
ip route 0.0.0.0 0.0.0.0 100.1.1.4 ide
三、配置 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 测试
==============================================================debug
静态NAT:
在这种类型的NAT中,私有地址与公有地址的对应关系是 1:1 , 不节省IP地址;code
在动态NAT的一种类型中 ---- PNAT(port NAT) ,
所造成的私有地址与公有地址的对应关系是:n:1 ,节省IP地址;
本质是:
使用同一个公网IP地址的,不一样的,端口号,来对应内网不一样的私有主机 router
配置思路:
一、肯定 NAT 边界
二、肯定须要进行 NAT 转换的私有地址空间server
工具 -匹配感兴趣的流量 内网中 全部 数据包源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端口 配置思路: 1.准备环境 2.进接口,肯定in、out 3.静态nat
思科:
ip nat inside source list 1 interface FastEthernet0/1 overload //pnat pat 端口多路复用 动态nat ip nat inside source static tcp 192.168.1.1 23 200.1.1.3 6969 extendable //nat高级应用——端口映射 ip nat inside source static 192.168.1.1 200.1.1.3 //静态nat 怎么把路由器搞成PC? conf t no ip routing //关闭路由功能 ip default-gateway 地址 若是不这么干,那么,你须要配置路由条目,才能和你的网关通讯
==========================================
华为:
静态nat interface GigabitEthernet0/0/1 ip address 200.1.1.3 255.255.255.0 nat static global 200.1.1.5 inside 192.168.1.1 netmask 255.255.255.255 //先打公网地址(不能和你的外部接口地址一致),再输内部地址 nat static enable //开服务 动态nat [Huawei]acl 2000 //建立acl rule 5 permit //建立规则 nat outbound 2000 //应用acl nat高级应用 nat server protocol tcp global 200.1.1.10 6969 inside 192.168.1.2 www //高级应用 端口映射: 内网访问外网,写默认路由到外网便可 端口映射的场景:外网访问内网,必须使用端口映射,(若是不作,只能访问到边 界路由器,没法访问到内网),把目标地址进行转换,首先必须开 启nat功能