20
第第第第 第第第第第第 NAT

第十九章 网络地址翻译 NAT

  • Upload
    finola

  • View
    95

  • Download
    3

Embed Size (px)

DESCRIPTION

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

Citation preview

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

第十九章网络地址翻译 NAT

Page 2: 第十九章 网络地址翻译  NAT

2Cisxo Education Solution

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

Page 3: 第十九章 网络地址翻译  NAT

3Cisxo Education Solution

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

Page 4: 第十九章 网络地址翻译  NAT

4Cisxo Education Solution

Chapter Activities

Windows 95 PC Modem

Branch office

ISDN/analog

Small office

Central site

Frame Relay

Frame Relayservice

PRI

BRI

BRI

Frame Relay

Async

AAA server

AsyncSA

10.1.1.1

166.1.1.1SA

Inside Local IP Address

10.1.1.1

Inside Global IP Address

166.1.1.1

NAT table

PAT

Page 5: 第十九章 网络地址翻译  NAT

5Cisxo Education Solution

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

Page 6: 第十九章 网络地址翻译  NAT

6Cisxo Education Solution

NAT 术语

Internet

Inside

10.1.1.1Inside Local IP

Address

10.1.1.1

Simple NAT tableInside Global IP Address

166.1.1.1

10.1.1.2

Host B172.20.7.3

A

C

BA

B

D

SA10.1.1.1

DA10.1.1.1

SA166.1.1.1

DA166.1.1.1

D

C

Page 7: 第十九章 网络地址翻译  NAT

7Cisxo Education Solution

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

Page 8: 第十九章 网络地址翻译  NAT

8Cisxo Education Solution

NAT 功能

Inside Local IP Address

10.1.1.110.1.1.2

NAT tableInside Global IP Address

196.168.2.2196.168.2.3

• NAT 功能 :- 内部网络地址转换- 复用内部的全局地址- TCP 负载均衡- 解决网络地址重叠

Internet

Inside

10.1.1.1

10.1.1.2

Page 9: 第十九章 网络地址翻译  NAT

9Cisxo Education Solution

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

Page 10: 第十九章 网络地址翻译  NAT

10Cisxo Education Solution

复用内部的全局地址

10.1.1.2:172310.1.1.1:1024

NAT table

196.168.2.2:1723196.168.2.2:1024

TCPTCP

10.1.1.3:1492 196.168.2.2:1492TCP

Internet

Inside

10.1.1.1

Host B179.20.7.3

1

3

SA10.1.1.1

DA10.1.1.1

SA196.168.2.2

DA196.168.2.2

10.1.1.2

10.1.1.3

4

5

2Host C

179.21.7.3

DA196.168.2.2

4

Inside Global IP Address: Port

Protocol Inside Local IP Address: Port10.1.1.1

Page 11: 第十九章 网络地址翻译  NAT

11Cisxo Education Solution

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

Page 12: 第十九章 网络地址翻译  NAT

12Cisxo Education Solution

TCP 负载均衡

NAT tableInside Global IP Address: Port 10.1.1.127:8010.1.1.127:8010.1.1.127:80

Protocol

TCPTCPTCP

Inside Local IP Address: Port

10.1.1.1:8010.1.1.2:8010.1.1.3:80

Internet

Inside

10.1.1.1

Host B176.20.7.34 5

SA10.1.1.1

DA10.1.1.1

SA10.1.1.127

DA10.1.1.127

10.1.1.2

10.1.1.1

13

2

Host C176.21.7.3

10.1.1.127

10.1.1.3

Virtualhost

Realhosts

Page 13: 第十九章 网络地址翻译  NAT

13Cisxo Education Solution

NAT 三种类型• NAT 有三种类型:静态 NAT ( staticNAT )、 NAT 池

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

Page 14: 第十九章 网络地址翻译  NAT

14Cisxo Education Solution

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

Page 15: 第十九章 网络地址翻译  NAT

15Cisxo Education Solution

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

Page 16: 第十九章 网络地址翻译  NAT

16Cisxo Education Solution

ip nat pool dyn-nat 192.16.2.1 192.16.2.254 netmask 255.255.255.0ip 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!

动态 NAT 的配置

Translate between inside hosts addressed from 10.1.1.0/24 to the globally unique 192.16.2.0/24 network.

This interface connected to the outside world.

This interface connected to the inside network.

Page 17: 第十九章 网络地址翻译  NAT

17Cisxo Education Solution

PAT 的配置ip nat pool ovrld-nat 192.16.2.1 192.16.2.2

netmask 255.255.255.0ip 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

Page 18: 第十九章 网络地址翻译  NAT

18Cisxo Education Solution

Router#sh ip nat transPro Inside global Inside local Outside local Outside globaltcp 192.2.2.1:11003 10.1.1.1:11003 172.16.2.2:23 172.16.2.2:23tcp 192.2.2.1:1067 10.1.1.2:1067 172.16.2.3:23 172.16.2.3:23

Verifying NAT

A translation for a Telnet is still active. Two different inside hosts appear on the outside with a single IP address.

Basic IP address translation

Unique TCP port numbers are used to distinguishbetween hosts.

Router#show ip nat transPro 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

Page 19: 第十九章 网络地址翻译  NAT

19Cisxo Education Solution

Router#debug ip natNAT: 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]

Troubleshooting NAT

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.

Page 20: 第十九章 网络地址翻译  NAT

20Cisxo Education Solution

Clearing NAT Translation Entries

All entries are cleared.

192.16.2.2 is cleared.

Router#sh ip nat transPro Inside global Inside local Outside local Outside globaltcp 192.16.2.1:11003 10.1.1.1:11003 172.16.2.2:23 172.16.2.2:23tcp 192.16.2.1:1067 10.1.1.2:1067 172.16.2.3:23 172.16.2.3:23router#clear ip nat trans *router#router#show ip nat trans

router#show ip nat transPro Inside global Inside local Outside local Outside globaludp 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:23tcp 192.16.2.1:1067 10.1.1.1:1067 172.16.2.3:23 172.16.2.3:23router#clear ip nat trans udp inside 192.16.2.2 10.1.1.2 1220171.69.2.132 53 171.69.2.132 53 router#show ip nat transPro Inside global Inside local Outside local Outside globaltcp 192.16.2.1:11003 10.1.1.1:11003 172.16.2.2:23 172.16.2.2:23tcp 192.16.2.1:1067 10.1.1.3:1067 172.16.2.3:23 172.16.2.3:23