nat.
md 2025-05-19
NAT :: NETWORK ADDRESS TRANSLATION
used by firewalls or routers to translate private ip into public ips when sending data over the internet.
it is used :
when we dont have enough public ips.
ads security to internal ips.
how it works :
a deveiec with private ip wants to visit a website.
the router changes the ip to its own public ip.
the server responds to the public ip.
the router uses nat table to forward the reply back to private ip.
nat types:
SNAT : used when going out to the internat.
DNAT : used when accessing the internal.
PAT : when multiple private uses the same public ip by assigning different ports.
STATIC NAT
created one to one mapping between private and public ip.
creating the translation rule.
Router(config)# ip nat inside source static [private-IP] [public-IP]
tell the router which interface is internal and which is external.
Router(config)# interface fa0/0
Router(config-if)# ip nat inside
Router(config)# interface fa0/1
Router(config-if)# ip nat outside
DYNAMIC NAT
maps private ips to a pool of public ips. (ssign the available.)
pool of public ip is a range of ip addresses that can be assigned to internal devices.
define the internal
1/4
[Link] 2025-05-19
interface [inside-interface]
ip address [inside-IP] [subnet-mask]
ip nat inside
////
interface fa0/0
ip address [Link] [Link]
ip nat inside
no shutdown
define the external
interface [outside-interface]
ip address [outside-IP] [subnet-mask]
ip nat outside
////
interface fa0/1
ip address [Link] [Link]
ip nat outside
no shutdown
define nat pool
ip nat pool [POOL-NAME] [start-public-IP] [end-public-IP] netmask [netmask]
////
ip nat pool MYPOOL [Link] [Link] netmask [Link]
define access list for private ips
<!-- specify the range of internal ip that will be translated -->
access-list [number] permit [internal-subnet] [wildcard-mask]
////
access-list 1 permit [Link] [Link]
link the access list to nat pool
2/4
[Link] 2025-05-19
ip nat inside source list [number] pool [POOL-NAME]
////
ip nat inside source list 1 pool MYPOOL
NAT OVERLOAD (PAT)
multiple private share one public but different tcp/udp ports.
start with defining the inside and outside interfaces.
create the acl to define the private networks to translate
access-list 1 permit [Link] [Link]
configure the pat using public interface
ip nat inside source list 1 interface FastEthernet0/1 overload
<!-- FastEthernet0/1 is the outside interface -->
PAT WITH POOL OF PUBLIC IP ADDRESSES
start with defining the inside and outside interfaces.
create the acl to define the private networks to translate
define nat pool
ip nat pool MYPOOL [Link] [Link] netmask [Link]
configure the pat with the pool
ip nat inside source list 1 pool MYPOOL overload
CHECKING THE NAT
show ip nat statistics
show ip nat translation
3/4
[Link] 2025-05-19
show ip nat translation verbose (more detailed)
clear ip nat translation *
4/4