What are SNAT and DNAT

What are SNAT and DNAT
5 (100%) 2 votes

If you are working as a DevOps you must have heard the name NAT. In this article, we will talk about them and SNAT and DNAT.

NAT (Network Address translator) is generally used when you want to hide one side of the network and show it as a single IP. NAT keep a connection table so that it can forward the returning traffic to the private location. NAT make changes to either source or the destination address in headers and then forwards the packet. Based on this header change, NAT is divided into SNAT or DNAT.

SNAT

In this type of NAT, the source IP of the packet changes and then passes it to the interface. In this case, the destination will not be able to see who actually created the requests. SNAT allow hosts inside to connect to particular host outside.

All the hosts behind the SNAT are identified as one entity. This helps in scenarios where you want the third parties to whitelist your IP’s so that they can identify you. In this case, you create a SNAT and they can identify you by your SNAT IP.

snat

DNAT

These are the NATs where destination IPs are changed in headers and then passed to the interface. DNAT allows hosts from outside to connect to particular host inside.

This can be used in the example where you want to host it something locally with private up and want your NAT box to forward to this host whenever someone tries to contact to NAT IP. So, in short, your NAT IP will be your website IP.

dnat

Both of these NATs keep a connection table with them where they keep track of what headers they changed and the mapping to which it is changed to. So that they can pass the returning packet to the correct location.

This was about SNAT and DNAT. We will talk about more such things in this series on networking till then subscribe and stay updated.

Till then you can read about these articles on working on scale


Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.