1 / 20

第十九章 网络地址翻译 NAT

第十九章 网络地址翻译 NAT. NAT —— 网络地址翻译. 随着 Internet 的飞速发展,网上丰富的资源产生着巨大的吸引力 接入 Internet 成为当今信息业最为迫切的需求 但这受到 IP 地址的许多限制 首先,许多局域网在未联入 Internet 之前,就已经运行许多年了,局 域网上有了许多现成的资源和应用程序,但它的 IP 地址分配不符合 Internet 的国际标准,因而需要重新分配局域网的 IP 地址,这无疑是 劳神费时的工作 其二,随着 Internet 的膨胀式发展,其可用的 IP 地址越来越少,要想

finola
Download Presentation

第十九章 网络地址翻译 NAT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第十九章网络地址翻译 NAT

  2. NAT——网络地址翻译 • 随着Internet的飞速发展,网上丰富的资源产生着巨大的吸引力 • 接入Internet成为当今信息业最为迫切的需求 • 但这受到IP地址的许多限制 • 首先,许多局域网在未联入Internet之前,就已经运行许多年了,局 域网上有了许多现成的资源和应用程序,但它的IP地址分配不符合 Internet的国际标准,因而需要重新分配局域网的IP地址,这无疑是 劳神费时的工作 • 其二,随着Internet的膨胀式发展,其可用的IP地址越来越少,要想 在ISP处申请一个新的IP地址已不是很容易的事了

  3. NAT(网络地址翻译)能解决不少令人头疼的问题NAT(网络地址翻译)能解决不少令人头疼的问题 • 它解决问题的办法是:在内部网络中使用内部地址,通过NAT把内部地址翻译成合法的IP地址,在Internet上使用 • 其具体的做法是把IP包内的地址池(内部本地)用合法的IP地址段(内部全局)来替换

  4. Chapter Activities Frame Relay service NAT table Inside Local Inside Global IP IP Address Address 10.1.1.1 166.1.1.1 PAT Central site Async SA 10.1.1.1 AAA server BRI PRI Frame Relay SA 166.1.1.1 ISDN/analog Windows 95 PC Async Modem Small office BRI Frame Relay Branch office

  5. NAT 术语 • NAT 功能 • NAT 三种类型

  6. NAT 术语 Inside DA 166.1.1.1 D B Host B C 172.20.7.3 DA 10.1.1.1 SA 166.1.1.1 Internet 10.1.1.2 SA 10.1.1.1 A Simple NAT table 10.1.1.1 Inside Global Inside Local IP IP Address Address B A 166.1.1.1 10.1.1.1 D C

  7. 内部本地地址:私有IP,不能直接用于互连网。 • 内部全局地址:用来代替内部本地IP地址的,对外,或在互联网上是合法的的IP地址。

  8. NAT 功能 Inside • NAT 功能: • 内部网络地址转换 • 复用内部的全局地址 • TCP 负载均衡 • 解决网络地址重叠 Internet 10.1.1.2 10.1.1.1 NAT table Inside Local Inside Global IP Address IP Address 10.1.1.1 196.168.2.2 10.1.1.2 196.168.2.3

  9. 复用内部的全局地址 • 将一个内部全局地址用于同时代表多个内部局部地址。 • 主要用IP地址和端口号的组合来唯一区分各个内部主机。 • 目前在公司内普遍应用。(如下图)

  10. 复用内部的全局地址 Inside 4 DA 196.168.2.2 Host B 5 3 10.1.1.3 179.20.7.3 DA 10.1.1.1 4 SA 196.168.2.2 Internet DA 196.168.2.2 Host C 10.1.1.2 179.21.7.3 1 2 NAT table SA 10.1.1.1 Inside Local IP Inside Global IP Protocol 10.1.1.1 Address: Port Address: Port 10.1.1.1 TCP 10.1.1.3:1492 196.168.2.2:1492 TCP 10.1.1.2:1723 196.168.2.2:1723 TCP 10.1.1.1:1024 196.168.2.2:1024

  11. TCP 负载均衡 • TCP 负载均衡:用于将一台虚拟的主机映射到几台真实的主机上。(如下图)

  12. TCP 负载均衡 Inside 3 1 DA 10.1.1.1 DA 10.1.1.127 Host B 4 5 10.1.1.1 176.20.7.3 SA 10.1.1.1 SA 10.1.1.127 Realhosts Internet 10.1.1.2 Host C 176.21.7.3 2 NAT table Inside Local IP Inside Global IP Protocol 10.1.1.1 Address: Port Address: Port 10.1.1.3 TCP 10.1.1.1:80 10.1.1.127:80 Virtualhost TCP 10.1.1.2:80 10.1.1.127:80 TCP 10.1.1.3:80 10.1.1.127:80 10.1.1.127

  13. NAT三种类型 • NAT有三种类型:静态NAT(staticNAT)、NAT池(pooledNAT)和端口NAT(PAT)。 • 其中静态NAT设置起来最为简单,内部网络中的每个主机都被永久映 射成 外部网络中的某个合法的地址,多用于服务器。 • 而NAT池则是在外部网络中定义了一系列的合法地址,采用动态分配 的方法映射到内部网络,多用于网络中的工作站。 • PAT则是把内部地址映射到外部网络的一个IP地址的不同端口上。

  14. NAT静态映射实例 • interface Ethernet0 • ip address 172.16.1.1 255.255.255.0 • ip nat inside(指定内部接口) • ! • interface Serial0 • ip address 200.1.1.1 255.255.255.0 • ip nat outside (指定外部接口) • ! • ip nat inside source static 172.16.1.3 200.1.1.1 • (建立两个IP地址之间的静态映射) • ip classless • ip route 0.0.0.0 0.0.0.0 200.1.1.2

  15. 注意: • 从外网到内网建立静态映射后,外网能PING通内部全局地址(200.1.1.1),如果使用真实地址,则访问失败,这是因为从外网没有到达内网的路由存在! • Ping 172.16.1.3 …… • Ping 200.1.1.5 !!!!!

  16. 动态NAT的配置 ip nat pool dyn-nat 192.16.2.1 192.16.2.254 netmask 255.255.255.0 ip nat inside source list 1 pool dyn-nat ! interface Ethernet0 ip address 10.1.1.1 255.255.255.0 ip nat inside ! interface Serial0 ip address 192.16.2.1 255.255.255.0 ip nat outside ! access-list 1 permit 10.1.1.0 0.0.0.255 ! This interface connected to the inside network. This interface connected to the outside world. Translate between inside hosts addressed from 10.1.1.0/24 to the globally unique 192.16.2.0/24 network.

  17. PAT的配置 ip nat pool ovrld-nat 192.16.2.1 192.16.2.2 netmask 255.255.255.0 ip nat inside source list 1 pool ovrld-nat overload ! interface Ethernet0/0 ip address 10.1.1.1 255.255.255.0 ip nat inside ! interface Serial0/0 ip address 192.16.2.1 255.255.255.0 ip nat outside ! access-list 1 permit 10.1.1.0 0.0.0.255

  18. Verifying NAT Basic IP address translation Router#show ip nat trans Pro Inside global Inside local Outside local Outside global --- 192.2.2.1 10.1.1.1 --- --- --- 192.2.2.2 10.1.1.2 --- --- IP address translation with overloading Router#sh ip nat trans Pro Inside global Inside local Outside local Outside global tcp 192.2.2.1:11003 10.1.1.1:11003 172.16.2.2:23 172.16.2.2:23 tcp 192.2.2.1:1067 10.1.1.2:1067 172.16.2.3:23 172.16.2.3:23 Unique TCP port numbers are used to distinguishbetween hosts. A translation for a Telnet is still active. Two different inside hosts appear on the outside with a single IP address.

  19. Troubleshooting NAT Router#debug ip nat NAT: s=10.1.1.1->192.16.2.1, d=172.166.2.2 [0] NAT*: s=172.166.2.2, d=192.16.2.1->10.1.1.1 [0] NAT: s=10.1.1.1->192.16.2.1, d=172.166.2.2 [1] NAT: s=10.1.1.1->192.16.2.1, d=172.166.2.2 [2] NAT: s=10.1.1.1->192.16.2.1, d=172.166.2.2 [3] NAT*: s=172.166.2.2, d=192.16.2.1->10.1.1.1 [1] NAT: s=10.1.1.1->192.16.2.1, d=172.166.2.2 [4] NAT: s=10.1.1.1->192.16.2.1, d=172.166.2.2 [5] NAT: s=10.1.1.1->192.16.2.1, d=172.166.2.2 [6] NAT*: s=172.166.2.2, d=192.16.2.1->10.1.1.1 [2] An example address translation inside-to-outside. A reply to the packet sent. An example TCP conversation, inside-to-outside. * Indicates translation was in the fast path.

  20. Clearing NAT Translation Entries Router#sh ip nat trans Pro Inside global Inside local Outside local Outside global tcp 192.16.2.1:11003 10.1.1.1:11003 172.16.2.2:23 172.16.2.2:23 tcp 192.16.2.1:1067 10.1.1.2:1067 172.16.2.3:23 172.16.2.3:23 router#clear ip nat trans * router# router#show ip nat trans All entries are cleared. router#show ip nat trans Pro Inside global Inside local Outside local Outside global udp 192.16.2.2:1220 10.1.1.2:1120 171.69.2.132:53 171.69.2.132:53 tcp 192.16.2.1:11003 10.1.1.1:11003 172.16.2.2:23 172.16.2.2:23 tcp 192.16.2.1:1067 10.1.1.1:1067 172.16.2.3:23 172.16.2.3:23 router#clear ip nat trans udp inside 192.16.2.2 10.1.1.2 1220 171.69.2.132 53 171.69.2.132 53 router#show ip nat trans Pro Inside global Inside local Outside local Outside global tcp 192.16.2.1:11003 10.1.1.1:11003 172.16.2.2:23 172.16.2.2:23 tcp 192.16.2.1:1067 10.1.1.3:1067 172.16.2.3:23 172.16.2.3:23 192.16.2.2 is cleared.

More Related