Key Takeaway

<aside> 💡

In this section, we’ll discuss the purpose of Source NAT (SNAT) and observe how SNAT affects our packets through three ****small experiments.

</aside>

Source NAT (SNAT)

What is SNAT ?

In the previous section (@6. Understanding the Relationship Between iptables, Docker, and Linux Bridge), we mentioned that iptables is a user-space tool that allows users to configure and interact with the Linux kernel’s Netfilter system.

In common use cases, users employ iptables to define firewall rules or packet translation rules.

Among these, Source NAT (SNAT) is a feature implemented by Netfilter that modifies the source IP address or port of packets, allowing internal network hosts to communicate with external networks using a single public IP address.

In other words, iptables provides the configuration interface, while the Netfilter subsystem in the Linux kernel actually performs the SNAT operation and packet transformation.

Two Types of SNAT

In iptables, there are two built-in NAT targets used for Source NAT (SNAT), but they differ in how the source IP is set:

Type 1: SNAT

Type 2: MASQUERADE