NAT and PAT

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

NAT ( Network Address Translation )

Network Address Translation :

When communicating to devices in a public network, your


device needs to use a source address that is a public address.
NAT device enables private IPv4 to connect to the Internet. NAT
enables you to change an IP address in a packet to a different
address. Usually, NAT connects two networks and translates the
private (inside local) addresses into public addresses (inside
global) before packets are forwarded to another network. In
other words, Address translation allows you to translate your
internal private addresses to public addresses before these
packets leave your network
SITUATIONS TO USE NAT

The situations where to use NAT

•Your ISP did not provide you sufficient public IP address


•Your company is going to merge with a company that
uses the same address space
•Where you want to hide your internal IP address space
from outside
You want to assign the same IP address to multiple
machines The situation
TYPES OF NAT
There are three types of NAT

Static NAT / Dynamic NAT / PAT

Static NAT: In static NAT manual translation is performed by


an address translation device, translating one IP address to a
different one. If you have 100 devices, you need to create
100 static entries in the address translation table. Typically,
static translation is done for inside resources that outside
people want to access
DYANMIC NAT

Dynamic NAT is mostly used when inside users need to access outside resources. The global
address assigned to the internal user isn't important, since outside devices don't directly
connect to your internal users they just return traffic to them that the inside user requested.
Dynamic NAT is used when the inside user wants to access external resources. When an inside
user sends traffic through the address translation device, say a router, it examines the source
IP address and compares it to the internal local address pool. If it finds a match, then it
determines which inside global address pool it should use for the translation. It then
dynamically picks an address in the global address pool that is not currently assigned to an
inside device. The router adds this entry in its address translation table, the packet is
translated, and the packet is then sent to the outside world. If no matching entry is found in
the local address pool, the address is not translated and is forwarded to the outside world in
its original state.
When returning traffic comes back into your network, the address translation device examines
the destination IP addresses and checks them against the address translation table. Upon
finding a matching entry, it converts the global inside address to the local inside address in the
destination IP address field of the packet header and forwards the packet to the inside
network
USE CASE
PAT ( PORT ADDRESS TRANSLATION
With PAT, all devices that go through the address translation device have the same global IP
address assigned to them, so the source TCP or UDP port numbers are used to differentiate
the different connections. If two devices have the same source port number, the translation
device changes one of them to ensure uniqueness.
The major difference between NAT and PAT is In NAT Only IP addresses are translated (not
port numbers).

DISADVANTAGES OF NAT

Three main disadvantages with address translation are:

• Each connection has an added delay.


• Troubleshooting is more difficult.
• Not all applications work with address translation
EXPLANATIONS OF TERMS TO BE USED
Term Explanation

Inside Addresses located on the inside of your network

Outside Addresses located outside of your network

Local The IP address physically assigned to a device

Global The public IP address physically or logically assigned to a device

Inside local IP address The IPv4 address that is assigned to a host on the inside network

A legitimate IPv4 address assigned by the ISP that represents one or more inside local IPv4
Inside global IP address
addresses to the outside world

Outside global IP address An outside device with a registered public IP address

Outside local IP address An outside device with an assigned private IP address

Static NAT A manual address translation is performed between two addresses and possibly port numbers.

An address translation device automatically performs address translation between two addresses
Dynamic NAT
and possibly port numbers.

Many inside IP addresses are translated to a single IP address, where each inside address is given a
Port Address Translation (PAT)
different TCP or UDP port number for uniqueness.
STATIC NAT CONFIGURATION
Configuration of static NAT is very straightforward. In this example, we have a web server
connected with Router 1. Our web server is using the IP address 10.0.0.2. But due to various
reasons discussed in the previous slide our company wants to use a 50.0.0.1 IP address for
this server. Now our task is to configure NAT on Router 1 which translate 10.0.0.2 [ inside local
web server address] to 50.0.0.1 [ inside global ip address ].

First configure the topology with mentioned networks and IP addresses, for NAT configurations
STATIC NAT CONFIGURATION FOR R1
R1(config)#ip route 30.0.0.0 255.0.0.0 20.0.0.1
R1(config)#ip nat inside source static 10.0.0.2 50.0.0.1
R1(config)#int fa 0/0
R1(config-if)#ip nat inside
R1(config)#int s 0/0/0
R1(config-if)#ip nat outside
R1(config-if)#exit
R1(config)#exit
R1#copy run start

STATIC NAT CONFIGURATION FOR R0


R0(config)int s0/1/0
R(config-if)#bandwidth 64
R0(config-if)#exit
R0(config)#ip route 50.0.0.0 255.0.0.0 20.0.0.2
As you have seen in the configuration there is no direct route for 10.0.0.2. So PC from a
network of 30.0.0.0 will never know about it. They will access 50.0.0.1 as the web server IP. To
test it double click on any computer and ping from 50.0.0.1 and you will get a reply.
VERIFICATION OF CONFIGURATION
DYNAMIC NAT CONFIGURATION
Step by Step Configuration of Dynamic NAT
With dynamic NAT, you must manually define two sets of addresses on your address
translation device. One set defines which inside addresses are allowed to be translated (the
local addresses), and the other defines what these addresses are to be translated to (the
global addresses).

First configure the topology with mentioned networks and IP addresses, for DYNAMIC NAT
configurations
In this topology, our internal network is using a 192.168.0.0
network. We have five public ip addresses 50.0.0.1 to
50.0.0.5 to use. Router1(1841 Router0) is going to be a NAT
device. Double click on Router1(1841 Router0) and
configure it as given below

DYNAMIC NAT CONFIGURATION FOR R0


R0(config-if)#bandwidth 64
R0(config)#ip route 0.0.0.0 0.0.0.0 30.0.0.2
R0(config)#access-list 1 permit 192.168.0.0 0.0.0.255
R0(config)#ip nat pool test 50.0.0.1 50.0.0.5 netmask 255.0.0.0
R0(config)#ip nat inside source list 1 pool test
R0(config)#interface fastEthernet 0/0
R0(config-if)#ip nat inside
R0(config-if)#exit
R0(config)#interface serial 0/0/0
R0(config-if)#ip nat outside
R0(config-if)#exit

DYNAMIC NAT CONFIGURATION FOR R1


Router1(config)#ip route 0.0.0.0 0.0.0.0 30.0.0.1
Now check for web access from any client pc
PAT CONFIGURATION
Configuration of PAT
Dynamic Nat translations are made IP to IP. so you need as much global IP address as you have
an inside local address. That's an issue if you have few global IP addresses and hundred of
inside local addresses to translate. In such a situation you need to use PAT.
For demonstration, we are going to configure the same topology which we used in dynamic
NAT but this time we are using only one global IP address 50.0.0.1
PAT CONFIGURATION FOR R0 & R1
R0(config)#interface serial 0/0/0
R0(config-if)#bandwidth 64
R0(config-if)#exit
R0(config)#ip route 0.0.0.0 0.0.0.0 30.0.0.2
R0(config)#access-list 1 permit 192.168.0.0 0.0.0.255
R0(config)#ip nat pool test 50.0.0.1 50.0.0.1 netmask 255.0.0.0
R0(config)#ip nat inside source list 1 pool test overload
R0(config)#interface fastethernet 0/0
R0(config-if)#ip nat inside
R0(config-if)#exit
R0(config)#interface serial 0/0/0
R0(config-if)#ip nat outside
R0(config-if)#exit
R0(config)#

R1(config)#ip route 0.0.0.0 0.0.0.0 30.0.0.1

Now go on pc and ping to 20.0.0.2


IMPORTANT COMMANDS

To Verify DYNAMIC NAT

R#debug ip nat

R#undebug ip nat

To Verify PAT

R#show ip nat translations


For more information please visit our website
www.trainingbasket.in

You might also like