Tuesday, April 23, 2019

Implementation of network address translation in cisco packet tracer


NAT stands for "Network Address Translation." NAT translates the IP addresses of computers in a local network to a single IP address. This address is often used by the router that connects the computers to the Internet. Address translation reduces the need for IPv4 public addresses and hides private network address ranges. 

The Purpose of NAT
NAT serves three main purposes:

·         Provides a type of firewall by hiding internal IP addresses
·         Enables a company to use more internal IP addresses. Since they're used internally only, there's no possibility of conflict with IP addresses used by other companies and organizations.
·         Allows a company to combine multiple ISDN connections into a single Internet connection.

NAT conserves the number of globally valid IP addresses a company needs, and in combination with Classless Inter-Domain Routing (CIDR) has done a lot to extend the useful life of IPv4 as a result.
The NAT mechanism ("natting") is a router feature, and is often part of a corporate firewall. NAT gateways can map IP addresses in several ways:
·         From a local IP address to one global IP address statically;
·         From a local IP address to any of a rotating pool of global IP addresses a company may have;
·         From a local IP address plus a particular TCP port to a global IP address or one in a pool of ports;
·         From a global IP address to any of a pool of local IP addresses on a round-robin basis.

Types of NAT:
Static NAT:
Static NAT (Network Address Translation):
Static NAT (Network Address Translation) is one-to-one mapping of a private IP address to a public IP address. Static NAT (Network Address Translation) is useful when a network device inside a private network needs to be accessible from internet.
Dynamic NAT (Network Address Translation):

Dynamic NAT can be defined as mapping of a private IP address to a public IP address from a group of public IP addresses called as NAT pool. Dynamic NAT establishes a one-to-one mapping between a private IP address to a public IP address. Here the public IP address is taken from the pool of IP addresses configured on the end NAT router. The public to private mapping may vary based on the available public IP address in NAT pool.

 Advantages of NAT:

·         NAT conserves legally registered IP addresses .
·         It provides privacy as the device IP address, sending and receiving the traffic, will be hidden.
·         Eliminates address renumbering when a network evolves.

CONFIGURATION:
Topology:
                      
Create a n/w topology as shown in Figure 7.1. I have taken 2 PCs with IP address as 10.0.0.10, 10.0.0.20. These PCs are connected to a switch which is connected to a router Router1 with gig 0/1. The interface IP address of gig 0/1 is 10.0.0.1. The Router1 is connected to Router2 via a serial ports se 0/1/0 in both the routers.

The interface IP address for Router1 at se 0/1/0 is 100.0.0.1. The interface IP address for Router2 at se 0/1/0 is 100.0.0.2. Router2 is connected to a server whose IP address is 192.168.1.10 via gig 0/0 port whose interface IP address is 192.168.1.1.

Now run the following commands as below to setup static NAT.

ON ROUTER 1:
Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int gig 0/1
Router(config-if)#ip address 10.0.0.1 255.0.0.0
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
Router(config-if)#int se 0/1/0
Router(config-if)#ip address 100.0.0.1 255.0.0.0
Router(config-if)#no shut

%LINK-5-CHANGED: Interface Serial0/1/0, changed state to down
Router(config-if)#
Router(config-if)#
%LINK-5-CHANGED: Interface Serial0/1/0, changed state to up

Router(config-if)#exit
Router(config)#ip nat inside source static 10.0.0.10 50.0.0.10
Router(config)#int gig 0/1
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config)#int se 0/1/0
Router(config-if)#ip nat outside
Router(config-if)#exit
Router(config)#ip nat inside source static 10.0.0.20 50.0.0.20
Router(config)#ip nat inside source static 10.0.0.30 50.0.0.30
Router(config)#exit
Router(config)#ip route 200.0.0.0 255.255.255.0 100.0.0.2
Router(config)#exit

ON ROUTER 2:

Router>en
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int gig 0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shut

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
Router(config-if)#int se 0/1/0
Router(config-if)#ip address 100.0.0.2 255.0.0.0
Router(config-if)#no shut

Router(config-if)#
%LINK-5-CHANGED: Interface Serial0/1/0, changed state to up

Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/0, changed state to up

Router(config-if)#ip nat inside source static 192.168.1.10 200.0.0.10
Router(config)#int gig 0/0
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config)#int se 0/1/0
Router(config-if)#ip nat outside
Router(config-if)#exit
Router(config)#ip route 50.0.0.0 255.0.0.0 100.0.0.1
Router(config)#exit



 Ping snapshot of NAT:












No comments:

Post a Comment

Socket Programming using TCP Socket Socket: Sockets allow communication between two different processes on the same or different ma...