1 Comnet 2010 Communication Networks Recitation 7 Lookups & NAT.

27
1 Comnet 2010 Communication Networks Communication Networks Recitation 7 Recitation 7 Lookups & NAT Lookups & NAT
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    222
  • download

    1

Transcript of 1 Comnet 2010 Communication Networks Recitation 7 Lookups & NAT.

1Comnet 2010

Communication NetworksCommunication Networks

Recitation 7Recitation 7

Lookups & NATLookups & NAT

2Comnet 2010

Lookup and Forwarding EngineLookup and Forwarding Engine

header

payload

Packet

Router

Destination Address

Outgoing Port

Destination PortForwarding Table

Routing Lookup Data Structure

65.0.0.0/8

128.9.0.0/16

149.12.0.0/19

3

1

7

3Comnet 2010

0 224 232-1

128.9.0.0/16

65.0.0.0

142.12.0.0/19

65.0.0.0/8

65.255.255.255

Example Forwarding TableExample Forwarding Table

Destination IP PrefixDestination IP Prefix Outgoing PortOutgoing Port65.0.0.0/ 865.0.0.0/ 8 33

128.9.0.0/16128.9.0.0/16 11

142.12.0.0/19142.12.0.0/19 77

IP prefix: 0-32 bits

Prefix length

128.9.16.14

4Comnet 2010

Prefixes can OverlapPrefixes can Overlap

128.9.16.0/21 128.9.172.0/21

128.9.176.0/24

Find the longest matching prefix among all prefixes that match the destination address.

0 232-1

128.9.0.0/16142.12.0.0/1965.0.0.0/8

128.9.16.14

Longest matching prefix

5Comnet 2010

LPM in IP RoutersLPM in IP RoutersUsing 32 exact match algorithms for LPM!Using 32 exact match algorithms for LPM!

Exact matchagainst prefixes

of length 1

Exact matchagainst prefixes

of length 2

Exact matchagainst prefixes

of length 32

Network Address PortPriorityEncodeand pick

6Comnet 2010

LPM in IP RoutersLPM in IP RoutersBinary triesBinary tries

Example Prefixesa) 00001b) 00010c) 00011d) 001e) 0101f) 011g) 100h) 1010i) 1100

j) 11110000

e

f g

h i

j

0 1

a b c

d

7Comnet 2010

LPM in IP RoutersLPM in IP Routers“Patricia” trie“Patricia” trie

Example Prefixesa) 00001b) 00010c) 00011d) 001e) 0101f) 011g) 100h) 1010i) 1100

j) 11110000

e

f g

h i

j Skip 510000

0 1

a b c

d

8Comnet 2010

(exact match)

(range match)

Each prefix is encoded as a range,find narrowest enclosing range.

A

B

Binary Search Binary Search

9Comnet 2010

Private NetworkPrivate Network• Private IP Private IP network is an IP network that is not directly connected network is an IP network that is not directly connected

to the Internetto the Internet

• IP addresses in a private network can be assigned arbitrarily. IP addresses in a private network can be assigned arbitrarily. – Not registered and not guaranteed to be globally uniqueNot registered and not guaranteed to be globally unique

• Generally, private networks use addresses from the following Generally, private networks use addresses from the following experimental address ranges (experimental address ranges (non-routable addressesnon-routable addresses): ): – 10.0.0.0 – 10.255.255.25510.0.0.0 – 10.255.255.255– 172.16.0.0 – 172.31.255.255172.16.0.0 – 172.31.255.255– 192.168.0.0 – 192.168.255.255192.168.0.0 – 192.168.255.255

10Comnet 2010

Private AddressesPrivate Addresses

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

11Comnet 2010

Network Address Translation Network Address Translation (NAT)(NAT)

• NAT is a router function where IP addresses (and possibly port NAT is a router function where IP addresses (and possibly port numbers) of IP datagrams are replaced at the boundary of a numbers) of IP datagrams are replaced at the boundary of a private networkprivate network

• NAT is a method that enables hosts on private networks to NAT is a method that enables hosts on private networks to communicate with hosts on the Internetcommunicate with hosts on the Internet

• NAT is run on routers that connect private networks to the public NAT is run on routers that connect private networks to the public Internet, to replace the IP address-port pair of an IP packet with Internet, to replace the IP address-port pair of an IP packet with another IP address-port pair. another IP address-port pair.

12Comnet 2010

Basic operation of NATBasic operation of NAT

• NAT device has address translation NAT device has address translation tabletable

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

13Comnet 2010

Main uses of NATMain uses of NAT

• Pooling of IP addressesPooling of IP addresses

• Supporting migration between Supporting migration between network service providersnetwork service providers

• IP masqueradingIP masquerading

• Load balancing of serversLoad balancing of servers

14Comnet 2010

Pooling of IP addressesPooling of IP addresses

• Scenario:Scenario: Corporate network has many hosts but only a small Corporate network has many hosts but only a small number of public IP addressesnumber of public IP addresses

• NAT solution:NAT solution:– Corporate network is managed with a private address spaceCorporate network is managed with a private address space– NAT device, located at the boundary between the corporate NAT device, located at the boundary between the corporate

network and the public Internet, manages a pool of public IP network and the public Internet, manages a pool of public IP addresses addresses

– When a host from the corporate network sends an IP When a host from the corporate network sends an IP datagram to a host in the public Internet, the NAT device datagram to a host in the public Internet, the NAT device picks a public IP address from the address pool, and binds picks a public IP address from the address pool, and binds this address to the private address of the hostthis address to the private address of the host

15Comnet 2010

Pooling of IP addressesPooling of IP addresses

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

16Comnet 2010

Supporting migration between Supporting migration between network service providersnetwork service providers

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

• NAT solution:NAT solution:

– Assign private addresses to the hosts of the corporate networkAssign private addresses to the hosts of the corporate network

– NAT device has static address translation entries which bind the NAT device has static address translation entries which bind the private address of a host to the public address. private address of a host to the public address.

– Migration to a new network service provider merely requires an Migration to a new network service provider merely requires an update of the NAT device. The migration is not noticeable to the update of the NAT device. The migration is not noticeable to the hosts on the network. hosts on the network.

Note:Note:

– The difference to the use of NAT with IP address pooling is that the The difference to the use of NAT with IP address pooling is that the mapping of public and private IP addresses is static.mapping of public and private IP addresses is static.

17Comnet 2010

Supporting migration between Supporting migration between network service providersnetwork 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:

18Comnet 2010

IP masqueradingIP masquerading

• Also called: Network address and port translation Also called: Network address and port translation (NAPT), port address translation (PAT).(NAPT), port address translation (PAT).

• Scenario:Scenario: Single public IP address is mapped to Single public IP address is mapped to multiple hosts in a private network. multiple hosts in a private network.

• NAT solution:NAT solution:– Assign private addresses to the hosts of the Assign private addresses to the hosts of the

corporate networkcorporate network– NAT device modifies the port numbers for NAT device modifies the port numbers for

outgoing trafficoutgoing traffic

19Comnet 2010

IP masqueradingIP masquerading

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

20Comnet 2010

Load balancing of serversLoad balancing of servers

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

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

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

arriving packets to one of the private addresses for a serverarriving packets to one of the private addresses for a server– A sensible strategy for balancing the load of the servers is to A sensible strategy for balancing the load of the servers is to

assign the addresses of the servers in a round-robin fashion. assign the addresses of the servers in a round-robin fashion.

21Comnet 2010

Load balancing of serversLoad 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

22Comnet 2010

Concerns about NATConcerns about NAT

• Performance:Performance:

– Modifying the IP header by changing Modifying the IP header by changing the IP address requires that NAT the IP address requires that NAT boxes recalculate the IP header boxes recalculate the IP header checksumchecksum

– Modifying port number requires that Modifying port number requires that NAT boxes recalculate TCP NAT boxes recalculate TCP checksumchecksum

23Comnet 2010

Concerns about NATConcerns about NAT

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

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

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

a private network need to communicate with each a private network need to communicate with each other.other.

24Comnet 2010

Concerns about NATConcerns about NAT

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

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

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

25Comnet 2010

NAT and FTPNAT and FTP

H1 H2

public address:128.143.72.21

FTP client FTP server

PORT 128.143.72.21/1027

200 PORT command successful

public address:128.195.4.120

RETR myfile

150 Opening data connection

establish data connection

• Normal FTP operationNormal FTP operation

26Comnet 2010

NAT and FTPNAT and FTP

• NAT device with FTP supportNAT device with FTP support

H1

Private network

NATdevice

H2

private address: 10.0.1.3public address: 128.143.72.21

Internet

FTP client FTP server

PORT 10.0.1.3/1027 PORT 128.143.72.21/1027

200 PORT command successful200 PORT command successful

RETR myfile

establish data connection

RETR myfile

150 Opening data connection150 Opening data connection

establish data connection

27Comnet 2010

NAT and FTPNAT and FTP

• FTP in passive mode and NAT.FTP in passive mode and NAT.

H1

Private network

NATdevice

H2

private address: 10.0.1.3public address: 128.143.72.21

Internet

FTP client FTP server

PASV PASV

Entering Passive Mode128.195.4.120/10001

Entering Passive Mode128.195.4.120/10001

public address:128.195.4.120

Establish data connection Establish data connection