1 network address translation (nat). 2 private network شبکه خصوصی شبکه ای است که...

17
1 Network Address Translation (NAT)

Upload: conrad-kennedy

Post on 28-Dec-2015

237 views

Category:

Documents


0 download

TRANSCRIPT

1

Network Address Translation (NAT)

2

Private Network

شبکه خصوص�ی ش�بکه ای اس�ت ک�ه بط�ور مس�تقیم ب�ه این�ترنت متص�ل •نیست

ب�ه دلخ�واه تخص�یص داده می IPدر ی�ک ش�بکه خصوص�ی آدرس ه�ای •شوند و هیچ تضمینی برای یکتا بودن سراسری آنها وجود ندارد

ه�ای • آدرس از ه�ای خصوص�ی ش�بکه کلی زی�ر IPبط�ور ه�ای رنج استفاده می کنند که آدرس های غیر قابل روتینگ هستند:

– 10.0.0.0 – 10.255.255.255– 172.16.0.0 – 172.31.255.255– 192.168.0.0 – 192.168.255.255

3

مثال

H1

R1

H2

10.0.1.3

10.0.1.1

10.0.1.2

H3

R2

H4

10.0.1.310.0.1.2

Private network 1

Internet

H5

10.0.1.1Private network 1

213.168.112.3

128.195.4.119 128.143.71.21

4

Network Address Translation (NAT)

•NAT یکی از عملکرده�ای روت�ر اس�ت ک�ه توس�ط آن آدرس ه�ای IP خصوص�ی دیت�اگرام ه�ا )و در م�واردی ش�ماره پ�ورت ه�ا( در م�رز ی�ک

شبکه خصوصی تبدیل می شوند هاس�ت ه�ایی ک�ه در ش�بکه ه�ای خصوص�ی ق�رار دارن�د می NATتوس�ط •

توانند با هاست هایی که بر روی اینترنت هستند ارتباط برقرار کنند•NAT ب�ر روی روت�ر اج�را می ش�ود و IP خصوص�ی ی�ک هاس�ت را تب�دیل

عمومی( می کندIP معتبر و قابل روتینگ در اینترنت )IPبه یک

5

NATمثالی از

• NAT device has address translation table

H1

private address: 10.0.1.2public address: 128.143.71.21

H5

Privatenetwork

Internet

Source = 10.0.1.2Destination = 213.168.112.3

Source = 128.143.71.21Destination = 213.168.112.3

public address: 213.168.112.3NATdevice

Source = 213.168.112.3Destination = 128.143.71.21

Source = 213.168.112.3Destination = 10.0.1.2

PrivateAddress

PublicAddress

10.0.1.2 128.143.71.21

6

NATکاربردهای اصلی

•Pool کردن آدرس های IP

ایجاد امکان مهاجرت میان سرویس دهنده های مختلف اینترنت•

•IP masquerading تبدیل/تغییر شکل( IP)

•Load balancing of servers)توازن بار سرورها(

7

Pool کردن آدرس های IP

هاس�ت • زی�ادی تع�دادی ش�امل ش�رکت ی�ک ش�بکه سناریو: عم�ومی در اختی�ار IPاس�ت ولی ش�رکت فق�ط تع�داد مح�دودی

دارد:NATراه حل توسط •ه�ای • آدرس ش�رکت ش�بکه در ه�ا هاس�ت خصوص�ی IPبه

تخصیص داده می شود )روت�ر( ک�ه در م�رز بین ش�بکه خصوص�ی ش�رکت NATدس�تگاه •

گ�ر�فت�ه، �مخ�زنی ا�ین�ترنت� �ق�رار ه�ای (pool)�و� آدرس� از IP� عمومی را مدیریت می کند

را IPهنگ�امی ک�ه ی�ک هاس�ت در ش�بکه خصوص�ی ی�ک دیت�اگرام •فرس�تد،� س�خت �اف�زار� این�ترن�ت می ر�وی هاس�تی �ب�ر ب�رای�

NAT یکی از آد�رس ه�ای IP عم�ومی را ا�ز مخ�زن خ�ود �انتخ�اب می ک�ند و آن �را به آدرس �خصوصی هاست �متصل �می کن�د

8

مثال:

H1

private address: 10.0.1.2public address:

H5

Privatenetwork

Internet

Source = 10.0.1.2Destination = 213.168.112.3

Source = 128.143.71.21Destination = 213.168.112.3

public address: 213.168.112.3NATdevice

PrivateAddress

PublicAddress

10.0.1.2

Pool of addresses: 128.143.71.0-128.143.71.30

9

Supporting migration between network service providers

• Scenario: In CIDR, the IP addresses in a corporate network are obtained from the service provider. Changing the service provider requires changing all IP addresses in the network.

• NAT solution:– Assign private addresses to the hosts of the corporate network– NAT device has static address translation entries which bind the

private address of a host to the public address. – Migration to a new network service provider merely requires an update

of the NAT device. The migration is not noticeable to the hosts on the network.

Note:– The difference to the use of NAT with IP address pooling is that the

mapping of public and private IP addresses is static.

10

Supporting migration between network service providers

H1

private address: 10.0.1.2public address: 128.143.71.21

128.195.4.120

Source = 10.0.1.2Destination = 213.168.112.3

NATdevice

PrivateAddress

PublicAddress

10.0.1.2128.143.71.21128.195.4.120

128.143.71.21

128.195.4.120

Source = 128.143.71.21Destination = 213.168.112.3

Source = 128.195.4.120Destination = 213.168.112.3

ISP 2allocates address block

128.195.4.0/24 to privatenetwork:

Privatenetwork

ISP 1allocates address block

128.143.71.0/24 to privatenetwork:

11

IP masquerading تغییر شکل( IP)

و Network address and port translation (NAPT)این عمل•port address translation (PAT)نیز نامیده می شود

عمومی باید به چندین هاست در یک IPسناریو: یک آدرس •شبکه خصوصی نگاشت شود

:NATراه حل توسط • خصوصی به هاست ها در شبکهIPتخصیص آدرس های • برای NATتغییر شماره پورت ها توسط سخت افزار •

IPدیتاگرام های خروجی شبکه: چون تنها یک آدرس عمومی وجود دارد باید از ترکیب آن با شماره پورت یک

هاست را بصورت یکتا در شبکه خصوصی مشخص کرد

12

مثال:

H1

private address: 10.0.1.2

Private network

Source = 10.0.1.2Source port = 2001

Source = 128.143.71.21Source port = 2100

NATdevice

PrivateAddress

PublicAddress

10.0.1.2/2001 128.143.71.21/2100

10.0.1.3/3020 128.143.71.21/4444

H2

private address: 10.0.1.3

Source = 10.0.1.3Source port = 3020

Internet

Source = 128.143.71.21Destination = 4444

128.143.71.21

13

Load balancing of servers

• Scenario: Balance the load on a set of identical servers, which are accessible from a single IP address

• NAT solution:– Here, the servers are assigned private addresses – NAT device acts as a proxy for requests to the server from

the public network– The NAT device changes the destination IP address of

arriving packets to one of the private addresses for a server

– A sensible strategy for balancing the load of the servers is to assign the addresses of the servers in a round-robin fashion.

14

Load balancing of servers

Private network

Source = 213.168.12.3Destination = 128.143.71.21

NATdevice

PrivateAddress

PublicAddress

10.0.1.2 128.143.71.21

Inside network

10.0.1.4 128.143.71.21

Internet128.143.71.21

S1

S2

S3

10.0.1.4

10.0.1.3

10.0.1.2

PublicAddress

128.195.4.120

Outside network

213.168.12.3

Source = 128.195.4.120Destination = 128.143.71.21

15

Concerns about NAT

• Performance:– Modifying the IP header by changing the IP address

requires that NAT boxes recalculate the IP header checksum

– Modifying port number requires that NAT boxes recalculate TCP checksum

• Fragmentation– Care must be taken that a datagram that is fragmented

before it reaches the NAT device, is not assigned a different IP address or different port numbers for each of the fragments.

16

Concerns about NAT

• End-to-end connectivity:– NAT destroys universal end-to-end reachability of hosts on

the Internet. – A host in the public Internet often cannot initiate

communication to a host in a private network. – The problem is worse, when two hosts that are in a private

network need to communicate with each other.

17

Concerns about NAT

• IP address in application data:– Applications that carry IP addresses in the payload of the

application data generally do not work across a private-public network boundary.

– Some NAT devices inspect the payload of widely used application layer protocols and, if an IP address is detected in the application-layer header or the application payload, translate the address according to the address translation table.