NAT:network address translation 静态NAT: 在边界设备上,手动的建立 NAT 转换条目; 私有:公有 ===== 1:1 动态NAT: 在边界设备上,设备基于数据包触发而造成的 NAT 转换条目, 不须要人工干预。若是一个NAT转换条目在一段时间以内不使用, 在会自动的在 NAT 转换表中自动删除; -基本动态NAT 私有:公有 ===== 1:1 -P-NAT(端口复用) 私有:公有 ===== N:1 问题: 内网主动ping外网,是能够通的; 反之,则不通。 拓扑图:
静态NAT 配置命令:使用公网ip202.10.1.1 AR1 interface GigabitEthernet0/0/0 ip address 192.168.1.254 255.255.255.0 interface GigabitEthernet0/0/1 ip address 202.106.1.2 255.255.255.0 nat static global 202.10.1.1 inside 192.168.1.2 netmask 255.255.255.255 将公网ip202.10.1.1映射到内部ip为192.168.1.2的电脑上 nat static enable AR2 interface GigabitEthernet0/0/0 ip address 202.106.1.1 255.255.255.0 ip route-static 202.10.1.1 255.255.255.255 202.106.1.2 验证、测试: PC1作了静态NAT映射能够访问运营商
PC2没有作静态NAT映射不能够访问运营商
在R1与R2之间抓包验证已将私有ip转为公网ip
动态NAT就是在出口路由器上作一个公网地址池,内网ip访问外网时会在地 址池选择一个公网ip 配置命令:使用公网ip:202.10.1.1\202.10.1.2 建立基本ACL [Huawei]acl 2000 [Huawei-acl-basic-2000]rule 6 permit source 192.168.1.0 0.0.0.255 [Huawei-GigabitEthernet0/0/1]nat outbound 2000 address-group 1 no-pat //将ACL与地址池关联、no-pat表示不可反复使用 R2路由器配置静态路由 [R2]ip route-static 202.10.1.0 30 202.106.1.2 验证测试
这是用PC2访问公网时的包 由于地址池有俩个公网IP,只能ping通俩个包,不知是软件的缘由仍是我设 置的缘由求大神指点
PAT配置 公网ip使用公网端口ip PAT是将一个公网地址重复使用来访问外网 这里使用的ip为202.106.1.2 接上 删除公网地址池(注意必须先在端口解除关联) [R2-GigabitEthernet0/0/1]nat outbound 2000 // 反复使用当前接口ip 验证测试
静态端口映射配置: 在 PAT的配置上配置 interface GigabitEthernet0/0/1 ip address 202.106.1.2 255.255.255.0 nat static protocol tcp global current-interface telnet inside 192.168.1.4 teln et //作静态端口映射 能够经过外网远程访问内网 R3配置 [R3]user-interface vty 0 4 [R3-ui-vty0-4]authentication-mode aaa [R3-aaa]local-user admin password cipher admin123 [R3-aaa]local-user admin service-type telnet [R3-aaa]local-user admin privilege level 15 [R3]ip route-static 0.0.0.0 0.0.0.0 192.168.1.254 验证 在AR2路由器上Telnet 公网ip 映射到了192.168.1.4上
全部实验静态NAT、动态NAT、PAT已完成tcp