INTRODUCTION TO NAT
Welcome to the Introduction to NAT guide! This overview will give you a general understanding of Network Address Translation, or NAT, which is essential to the IPv4 networks we still use today. I mention IPv4 specifically because IPv6 renders NAT essentially purposeless as it provides enough IP addresses for everyone to have their own! But more on this later, let’s get started!
WHY NAT?
NAT stands for “Network Address Translation” and is not the same as a “Gnat,” which our readers from the Southern United States identify as a small winged insect that can wreak havoc on your picnic! Although NAT can be as irritating as a Gnat when configuring technology such as Video Conferencing, it is not the same spelling. The primary reason we have NAT is due to a lack of IPv4 IP address space to handle the massive number of devices we use every day.
An IPv4 address is 32 bits in size and contains 4,294,967,296 addresses. That sounds like a lot, but when you consider every server, computer, phone, smartwatch, electronic door lock, smart light bulb, etc., the number starts to sound a little smaller. If every one of these devices required a public IP address, we would have been out of IP addresses long ago! In fact, there are 2 BILLION (2,000,000,000) smartphones in existence alone! (http://thehub.smsglobal.com/smartphone-ownership-usage-and-penetration). So, how can an organization with thousands of servers give each one access to the internet without assigning public IP addresses? The answer is NAT!
HOW NAT WORKS
To understand how NAT works, we need to understand a few pieces of information:
PUBLIC VS. PRIVATE IP ADDRESSES
Private IP Addresses
Defined by “RFC 1918” as “non-routable” to the internet. This means that if a device is assigned one of these IP addresses, information from the internet cannot reach this device without a NAT in place. These addresses are as follows:
i. Class A: 10.0.0.0 – 10.255.255.255.255 (16,777,216 IP addresses)
ii. Class B: 172.16.0.0 – 172.31.255.255 (1,048,576 IP addresses)
iii. Class C: 192.168.0.0 – 192.168.255.255 (65,536 IP addresses)
Although the “class system” above can assist in choosing a proper range for your network, it is by no means a rule. If you want to create a network with 2 devices, you can use a Class A address and your boss probably won’t bat an eye, just make sure it has the proper “subnet mask” that doesn’t allocate too many addresses. (Subnet masks are a topic for another lesson.)
Public IP addresses
Public addresses are addresses that fall into any range not within the private IP guidelines. These are assigned by your ISP, who may have purchased their IP address blocks from one of the Regional Internet Registries. These registries are nearly out of IPv4 addresses, however, so many companies that need new IPv4 address blocks must purchase them from companies willing to sell ones they have already purchased.
PORTS AND SOCKETS
A “port” is a number between 0 and 65535. There are 1024 “well-known” port numbers that represent frequently used services, such as SSH (22) and HTTP (80).
A “Socket” is the IP address and the port together. For example: 192.168.1.1:22 is the SSH socket for the computer with IP address 192.168.1.1
You may be asking, “What do these things have to do with NAT?” Well I’ll tell you! NAT has 3 primary methods of operation:
1. Static: Static NAT is 1 private IP = 1 public IP. If your company has purchased 5 public IPs and they have 5 servers with private IPs, they will “map” each private IP to a public IP. Some organizations will map the public IP directly to the server, but NATting allows for the ability to change servers more easily and seamlessly without having the downtime required to remove the IP from one server and add it to another.
2. Dynamic: Dynamic NAT uses a pool of public IP addresses and maps them to private addresses in a random fashion, typically first come first served. If you have 5 servers with private IP addresses and 5 public IP addresses, the NAT gateway will assign public addresses to private addresses as the server needs them. So if one server with 192.168.1.1 tries to reach the internet, it will receive a public IP address when it attempts. When the server is finished communicating, it will return its IP back to the pool for another server to use.
3. Port Address Translation (Overloading): Port Address Translation is where the ports and sockets come into play. In “PAT,” each device with a private address connects using ports. So, one server may have its private IP address 192.168.1.1 mapped to socket 62.24.54.235:62838 and another with private IP address 192.168.1.2 mapped to 62.24.54.235:34839. Both have the same public IP address, but are using different ports. For incoming traffic, “Port Forwarding” is used. So, the Nat Gateway (typically your router) will see an incoming request for a service, such as SSH, and forward the connection to the appropriate port. If you have a server at 192.168.1.1 and you want to access it via SSH, you can forward port 22 to 192.168.1.1 and all requests to your public IP address will be forwarded to that server.
NAT EXAMPLES
Static NAT: An example of static NAT would be if someone named Tony Stark had a public phone number (Public IP address) and a private extension (Private IP address). If Steve Rogers called Tony at that public phone number, he would reach Tony without ever knowing Tony’s private extension. If Tony were to quit or get fired, another person could move into Tony’s desk and use their private extension. If Steve called that number back, he would be connected to Tony’s replacement.
Dynamic NAT: An example of Dynamic NAT would be if Tony and 4 other board members all had private phone numbers (Private IPs). Stark Industries has 5 public phone numbers (Public IPs). When any board member makes an outbound call, they are routed to whichever public line is open at the time. So the caller ID on the receiver’s end could show any one of the 5 public phone numbers (Public IP addresses) depending on which one was given to the caller.
Port Address Translation: Let’s say you need to “forward” a port to allow you to access a server from the outside world on port 22. In a static or dynamic NAT environment, this is not necessary; you just map the private IP address to the public IP address. But what if you only have one address? This is where port forwarding comes into play. Let’s use a phone operator example.
Let’s say Steve Rogers is trying to call Tony Stark. Steve Rogers only knows Tony Stark’s executive admin (Pepper Potts’) number, but does not have Tony’s private line. Pepper Potts’ number is the public IP address. Steve calls Pepper Potts who then connects Steve to Tony Stark. The caveat here is that the operator never gives Steve Tony’s phone number. In fact, Tony doesn’t have a public phone number and can ONLY be called by Pepper. This is the important aspect of NAT; it can provide an extra layer of security by only allowing necessary ports to be accessed without allowing anyone to connect to any port.
AWS NAT LAB!
We will run through an example in this guide, but check out the Linux Academy Lab for creating a NAT instance and NAT Gateway in AWS and try it for yourself.
We are going to create an AWS NAT gateway with just a few steps! This will allow your private EC2 instances to access the internet for things such as serving traffic or downloading updates. I am going to skip straight to the NAT configuration section. If you are unfamiliar with EC2 setup, please check out our AWS courses to get up to speed! There are also handy NAT tutorials within those as well!
1. First, we are going to access our VPC Dashboard and select “NAT Gateways”:

2. Next, we will select “Create NAT Gateway”

3. 3. Now we are going to select a *PUBLIC* subnet. This is the subnet that will allow traffic to access the NAT Gateway. After the NAT Gateway receives the traffic, it will process the traffic and send to the instances accordingly. We then need an Elastic IP for the NAT Gateway. If you haven’t already created one, click “Create New EIP” to have one created for you. Finally, we click “Create a NAT Gateway.”

4. After we create our NAT Gateway, we need to edit the route tables to allow traffic to access the gateway.

5. Once you are on the Route Tables screen, select the default route table created in your VPC. If you have created a custom one, use that. In this example, I have created a new route table called “test public.” Edit this route table and select “Add another route.” Enter “0.0.0.0/0” as the Destination, your NAT Gateway ID as the Target (yours will have a different ID than mine, but will begin with “nat-“) and click “Save.”

6. Now, we create a security group to ensure traffic is allowed to our NAT Gateway. Select “Security Groups” on the left side, select “Create Security Group,” give it a descriptive Name tag such as “NAT_SG,” a Group name of the same, a Description, and select the proper VPC. Then, select “Yes, Create.”

7. Finally, we add the appropriate “Inbound Rules.” Outbound rules are set to “Allow All” by default. If you wish to change this, you can do so by utilizing the same techniques as the inbound rules. Select your “NAT_SG” security group, click on the “Inbound Rules” tab, click “Add another rule.” In this example, we are going to allow HTTP traffic to this instance. We select “HTTP (80)” which automatically selects the TCP (6) protocol and a “Port Range” of 80. After this, we select the Source, which is your private subnet that contains the instances that require access. In this case, the subnet is “sg-1eb4f463.” You can also use the subnet as the source, if you wish. This will allow the private instances to access the NAT which has a route to the outside world, allowing your instances to access the internet!

Great! You have created your first NAT! Now that you have created it, you can access instances in your private subnets and update them, download packages, and serve websites using HTTP!
Welcome to the Introduction to NAT guide! This overview will give you a general understanding of Network Address Translation, or NAT, which is essential to the IPv4 networks we still use today. I mention IPv4 specifically because IPv6 renders NAT essentially purposeless as it provides enough IP addresses for everyone to have their own! But more on this later, let’s get started!
WHY NAT?
NAT stands for “Network Address Translation” and is not the same as a “Gnat,” which our readers from the Southern United States identify as a small winged insect that can wreak havoc on your picnic! Although NAT can be as irritating as a Gnat when configuring technology such as Video Conferencing, it is not the same spelling. The primary reason we have NAT is due to a lack of IPv4 IP address space to handle the massive number of devices we use every day.
An IPv4 address is 32 bits in size and contains 4,294,967,296 addresses. That sounds like a lot, but when you consider every server, computer, phone, smartwatch, electronic door lock, smart light bulb, etc., the number starts to sound a little smaller. If every one of these devices required a public IP address, we would have been out of IP addresses long ago! In fact, there are 2 BILLION (2,000,000,000) smartphones in existence alone! (http://thehub.smsglobal.com/smartphone-ownership-usage-and-penetration). So, how can an organization with thousands of servers give each one access to the internet without assigning public IP addresses? The answer is NAT!
HOW NAT WORKS
To understand how NAT works, we need to understand a few pieces of information:
PUBLIC VS. PRIVATE IP ADDRESSES
Private IP Addresses
Defined by “RFC 1918” as “non-routable” to the internet. This means that if a device is assigned one of these IP addresses, information from the internet cannot reach this device without a NAT in place. These addresses are as follows:
i. Class A: 10.0.0.0 – 10.255.255.255.255 (16,777,216 IP addresses)
ii. Class B: 172.16.0.0 – 172.31.255.255 (1,048,576 IP addresses)
iii. Class C: 192.168.0.0 – 192.168.255.255 (65,536 IP addresses)
Although the “class system” above can assist in choosing a proper range for your network, it is by no means a rule. If you want to create a network with 2 devices, you can use a Class A address and your boss probably won’t bat an eye, just make sure it has the proper “subnet mask” that doesn’t allocate too many addresses. (Subnet masks are a topic for another lesson.)
Public IP addresses
Public addresses are addresses that fall into any range not within the private IP guidelines. These are assigned by your ISP, who may have purchased their IP address blocks from one of the Regional Internet Registries. These registries are nearly out of IPv4 addresses, however, so many companies that need new IPv4 address blocks must purchase them from companies willing to sell ones they have already purchased.
PORTS AND SOCKETS
A “port” is a number between 0 and 65535. There are 1024 “well-known” port numbers that represent frequently used services, such as SSH (22) and HTTP (80).
A “Socket” is the IP address and the port together. For example: 192.168.1.1:22 is the SSH socket for the computer with IP address 192.168.1.1
You may be asking, “What do these things have to do with NAT?” Well I’ll tell you! NAT has 3 primary methods of operation:
1. Static: Static NAT is 1 private IP = 1 public IP. If your company has purchased 5 public IPs and they have 5 servers with private IPs, they will “map” each private IP to a public IP. Some organizations will map the public IP directly to the server, but NATting allows for the ability to change servers more easily and seamlessly without having the downtime required to remove the IP from one server and add it to another.
2. Dynamic: Dynamic NAT uses a pool of public IP addresses and maps them to private addresses in a random fashion, typically first come first served. If you have 5 servers with private IP addresses and 5 public IP addresses, the NAT gateway will assign public addresses to private addresses as the server needs them. So if one server with 192.168.1.1 tries to reach the internet, it will receive a public IP address when it attempts. When the server is finished communicating, it will return its IP back to the pool for another server to use.
3. Port Address Translation (Overloading): Port Address Translation is where the ports and sockets come into play. In “PAT,” each device with a private address connects using ports. So, one server may have its private IP address 192.168.1.1 mapped to socket 62.24.54.235:62838 and another with private IP address 192.168.1.2 mapped to 62.24.54.235:34839. Both have the same public IP address, but are using different ports. For incoming traffic, “Port Forwarding” is used. So, the Nat Gateway (typically your router) will see an incoming request for a service, such as SSH, and forward the connection to the appropriate port. If you have a server at 192.168.1.1 and you want to access it via SSH, you can forward port 22 to 192.168.1.1 and all requests to your public IP address will be forwarded to that server.
NAT EXAMPLES
Static NAT: An example of static NAT would be if someone named Tony Stark had a public phone number (Public IP address) and a private extension (Private IP address). If Steve Rogers called Tony at that public phone number, he would reach Tony without ever knowing Tony’s private extension. If Tony were to quit or get fired, another person could move into Tony’s desk and use their private extension. If Steve called that number back, he would be connected to Tony’s replacement.
Dynamic NAT: An example of Dynamic NAT would be if Tony and 4 other board members all had private phone numbers (Private IPs). Stark Industries has 5 public phone numbers (Public IPs). When any board member makes an outbound call, they are routed to whichever public line is open at the time. So the caller ID on the receiver’s end could show any one of the 5 public phone numbers (Public IP addresses) depending on which one was given to the caller.
Port Address Translation: Let’s say you need to “forward” a port to allow you to access a server from the outside world on port 22. In a static or dynamic NAT environment, this is not necessary; you just map the private IP address to the public IP address. But what if you only have one address? This is where port forwarding comes into play. Let’s use a phone operator example.
Let’s say Steve Rogers is trying to call Tony Stark. Steve Rogers only knows Tony Stark’s executive admin (Pepper Potts’) number, but does not have Tony’s private line. Pepper Potts’ number is the public IP address. Steve calls Pepper Potts who then connects Steve to Tony Stark. The caveat here is that the operator never gives Steve Tony’s phone number. In fact, Tony doesn’t have a public phone number and can ONLY be called by Pepper. This is the important aspect of NAT; it can provide an extra layer of security by only allowing necessary ports to be accessed without allowing anyone to connect to any port.
AWS NAT LAB!
We will run through an example in this guide, but check out the Linux Academy Lab for creating a NAT instance and NAT Gateway in AWS and try it for yourself.
We are going to create an AWS NAT gateway with just a few steps! This will allow your private EC2 instances to access the internet for things such as serving traffic or downloading updates. I am going to skip straight to the NAT configuration section. If you are unfamiliar with EC2 setup, please check out our AWS courses to get up to speed! There are also handy NAT tutorials within those as well!
1. First, we are going to access our VPC Dashboard and select “NAT Gateways”:

2. Next, we will select “Create NAT Gateway”

3. 3. Now we are going to select a *PUBLIC* subnet. This is the subnet that will allow traffic to access the NAT Gateway. After the NAT Gateway receives the traffic, it will process the traffic and send to the instances accordingly. We then need an Elastic IP for the NAT Gateway. If you haven’t already created one, click “Create New EIP” to have one created for you. Finally, we click “Create a NAT Gateway.”

4. After we create our NAT Gateway, we need to edit the route tables to allow traffic to access the gateway.

5. Once you are on the Route Tables screen, select the default route table created in your VPC. If you have created a custom one, use that. In this example, I have created a new route table called “test public.” Edit this route table and select “Add another route.” Enter “0.0.0.0/0” as the Destination, your NAT Gateway ID as the Target (yours will have a different ID than mine, but will begin with “nat-“) and click “Save.”

6. Now, we create a security group to ensure traffic is allowed to our NAT Gateway. Select “Security Groups” on the left side, select “Create Security Group,” give it a descriptive Name tag such as “NAT_SG,” a Group name of the same, a Description, and select the proper VPC. Then, select “Yes, Create.”

7. Finally, we add the appropriate “Inbound Rules.” Outbound rules are set to “Allow All” by default. If you wish to change this, you can do so by utilizing the same techniques as the inbound rules. Select your “NAT_SG” security group, click on the “Inbound Rules” tab, click “Add another rule.” In this example, we are going to allow HTTP traffic to this instance. We select “HTTP (80)” which automatically selects the TCP (6) protocol and a “Port Range” of 80. After this, we select the Source, which is your private subnet that contains the instances that require access. In this case, the subnet is “sg-1eb4f463.” You can also use the subnet as the source, if you wish. This will allow the private instances to access the NAT which has a route to the outside world, allowing your instances to access the internet!

Great! You have created your first NAT! Now that you have created it, you can access instances in your private subnets and update them, download packages, and serve websites using HTTP!
AIDE:
AIDE (Advanced Intrusion Detection Environment) is a file and directory integrity checker
It creates a database from the regular expression rules that it finds from the config file(s). Once this database is
Installation Procedure:
1. Install AIDE package on CentOS/RHEL:
# yum install -y aide
2. Check and adjust aide configuration file to fulfill your needs:
# vim /etc/aide. conf
3. Initialize AIDE database - it will scan all the files in folders that were included in the config file and save their hash as well as attributes info
Once initialized we may see below line
### AIDE database at /var/lib/aide/aide. db . new . gz initialized.
4. we need to modify newly created database with mv command
5. Check the database before making any changes
6. Make any changes Ex : touch /usr/sbin/mytestfile.txt( just relating any file to test)
7. You may consider keeping golden copy of AIDE database (default is set to /var/lib/aide/aide. db . gz ) is secure and read-only location. It will allow you to compare current system integrity to the golden copy.
To check what changed run:
# aide -C
A popular host-based intrusion detection system on Linux is tripwire . This software can keep track of many different filesystem data points in order to detect whether unauthorized changes have occurred.
In this article, we will discuss how to install and configure tripwire and Commands for installation
Install Tripwire.
# yum install tripwire -y
Creating site and local keyfile pass-phrases
# tripwire -setup-keyfiles
Initializing Tripwire Database
# tripwire --init
Modifying Tripwire policy file
# vi /etc /tripwire /twpol.txt
Once modifying all the files, update the tripwire policy file.
# tripwire --update-policy --secure-mode low /etc/tripwire /twpol.txt
Checking for any changes in files/directories
# tripwire --check --interactive
It will ask you to enter passwords
Now let us add a new file called Anil.
# touch Anil
Now check this file with tripwire ? check ? interactive command. You may find the file Anil under the Added section in the result
# tripwire --check --interactive
OR
# tripwire --check
It will not ask you to enter password
Viewing the tripwire report file
All tripwire report files having extension . twr are stored in /var/lib/tripwire /report/ directory. These are not text files, so you can? t view them using any editor. First convert them using the following command to human readable format.
# twprint --print-report --twrfile /var/lib/tripwire/report/server.ostechnix.com-20130510-124159.twr > /tmp/twrreport.txt
Now open the file using any editor.
# vi /tmp/twrreport.txt
Viewing tripwire configuration and policy file locations
To view the policy file locations enter the following command.
#twadmin --print-polfile
To view the configuration files enter the following command.
# twadmin --print-cfgfile
Scheduling Tripwire Check
You may find a cron file tripwire -check might be created automatically in the /etc/cron . daily/ directory. If it isn ? t created, open your crontab file and add lines as shown below. The following example will execute the tripwire daily at 5 am.
# vi /etc/crontab
# Tripwire Monitor process
00 5 * * * /usr/sbin/tripwire --check
OR
0 7 * * * /usr/sbin/tripwire --check > /mnt/tripwire
0 8 * * * /bin/mail -s "Tripwire" amullapudi@ciphercloud.com < /tmp/tripwire
It will check system at 7 AM of everyday, everyweek , every month, every year and it will send an email on same .
========================================================================
In previous post i have introduced simple networking command to keep track ip address
of any website.To day am going to tel you few simple networking commands to keep
keep track ip journey.
Commands:
1. tracert
2. netstat
3. nslookup
1.tracert:
Tracert (traceroute) is another command adopted from Unix system. When ever you try
to open any website from your computer.We request our computer to go to that website
IP address by hopping into a few router address and fetch the website for you,tracert
is networking command and which is used to track hopping path.
PROCEDURE:
1.Open Command prompt and type cmd.
From the above picture you can see it your trying to trace Google routing path from
your computer it has taken 12 router paths. and It differs with internet speed.
2.netstat:
Netstat displays the active TCP connections and ports on which the computer is listening, Ethernet statistics, the IP routing table, statistics for the IP, ICMP, TCP, and UDP protocols. Netstat also can be used to tracking your outbound or inbound connection to your computer, it’s useful to malicious connection. Let’s see the picture below to see the available switch in netstat.
PROCEDURE:
1.Open Command prompt and type cmd.
2.In command prompt simply type netstat
In above picture you can see all active networking connections.You can also find which
port correctly listings.type following command.
netstat -np TCP | find "80"
3.nslookup:
This command helps to diagnose the Domain Name System (DNS) infrastructure and comes with a number of sub-commands. Usually used by hackers to find out some useful information that you can’t find on search engine. In this tips and trick I’m only show you how to find server IP address or host name. Type nslookup and the enter the URL of website you want to know it’s IP address for example I use Google.
PROCEDURE:
2.In command prompt simply type nslookup
3.Type website name.
In above image you can see Google actually using couple of address. Google can be pinged
from any of above address.
Hi Students today i will guide you to share large files between windows systems using RJ45 LAN cable.Some times we need copy large amount of data between two systems.
Generally we students use Pen drives for making data copy but Pen drives have their
Own limitation Example: We have take dump of 50 GB data from another laptop here
If you use 4 GB pen drive you will have use it around 15 times to make sure all data get
Copied but this method leads to USB ports get damage and time consuming process.
Solutions:
1.File share use GHOSTING method
2.File share use CROSS LAN cable
File Sharing Using LAN Cable:
Requirements: Double End RJ45 LAN Cable, LAN Port Enabled Windows Systems
Procedure:
Step 1: First you have to configure IP address of both systems and Make sure both system
Are having same work group name. To know and configure work group name just
Right click MY COMPUTER Click on properties,You will see work group name and
Change settings option.Like picture shown bellow.
Step 2: Second you have to configure IP address of both systems.set sequence address.
Step 3: Do follow bellow steps to configure IP address
Step 3.1: Type Network in windows search. From results choose bellow option
Step 3.2: Then choose Adapter settings option from right sidebar
Step 3.3: Right click on LOCAL AREA NETWORK choose properties->select
IP V4 and choose properties option.
Step 3.4: Set Source----------->IP: 192.168.1.15
Destination----->IP: 192.168.1.16
Step 3.5 Once you got successfully configured IP Address. Put Cables in physical
Ports and restart both systems(Some times Required).
Step 4: Next you will need turn on network Discovery option by following bellow path
Control Panel\All Control Panel Items\Network and Sharing Center\Advanced
sharing settings
Step 5: After this open run box(Win+R) and type Work Group name of system from which
You would like to share data. It will ask for Credentials provide them.
Step 6: Next share files on source system follow picture shown bellow.
--->Right click on file you wants to share
--->Select second Tab and choose Advance Sharing
Step 7: After this Repeat step 5 on destination system.
Step 8: Thats it your done.
Please ask questions in comment section
Introduction
In this post am going to tel simple trick to know IP Address of any website.As known every
Web site is referenced by the special and unique id called IP address.We can easily know
it with PING command.
PING:
PING is a Networking command . This command is used to test weather the destination
Computer can communicate over the network. In technical terms PING sends an Internet
Control Message Protocol to destination computer and it waits for response. Response information Contains basic information like ip address size of data it returns all.
Procedure:
Step 1: Press Windows+R then RUN command box will come
Step 2: Just type cmd and press Enter As shown in bellow image
Step 3: After this Command prompt will come.
Step 4: Type following commands
->cd\
->ping www.websitename.com
Step 5: In my example i wrote www.dropbox.com as destination site name.
Step 6: You can see in above image 199.47.217.170 is IP address of Dropbox.com
Step 7: That's it your done.
Put your questions in Comment section









