how/network
At home you have one public IP, but behind the router there are 10 devices, all going to the internet at the same time. The trick is that the router "remembers" who to send what.
At home you have one public IP from your provider. But behind the router sit a laptop, a phone, a TV, and three IoT devices. They all go to the internet at the same time, and they all get answers back. How does one public IP serve them all?
The answer is NAT (Network Address Translation). On the fly, the router swaps the addresses in packet headers: for an outgoing packet it rewrites the "return address" to its own public one, and for an incoming reply it rewrites it back to the private address of the device inside the network. For this to work, the router remembers every active connection in a special table (see conntrack).
Press ▶ to watch the life cycle of one connection through NAT in both directions.
The client has the address 192.168.1.50, which is in the
private range. Providers drop such addresses on the internet: they
live only inside home and office networks.
On its own, the client cannot talk to 8.8.8.8 directly, because
its src address is "not real". It needs help from the router.
The conntrack table on the router is empty: no active connections.
recap
What to remember:
10.0.0.0/8, 172.16.0.0/12,
192.168.0.0/16) are not routed on the internet. Any such
packet gets dropped by the provider. So every private network needs
NAT to reach the outsideIf you want to get hands-on, there is the lesson intermediate-06-nat-and- masquerade with nftables configuration and the conntrack -L command.