Back to Articles
Cloud & Network5 min readHow Internet Requests Actually Work · Part 3 of 8

Public IP, Private IP, NAT, and Ports Explained

See how private devices share a public IPv4 address through NAT, how source and destination ports identify network flows, and why one server can safely run many services.

NATPortsPrivate IPPublic IPNetworking

A home or office can contain many devices with private addresses while presenting one public IPv4 address to the internet. NAT and ports make this work, but they solve different parts of the problem.

Public and Private Addressing

Private IPv4 ranges are used inside networks and are not routed across the public internet. Common examples begin with 10., 172.16 through 172.31, or 192.168. A laptop might be 192.168.1.20 inside a home while the router has a public-facing address supplied by the ISP.

A small local network

Laptop 192.168.1.20Phone 192.168.1.21Camera 192.168.1.22Gateway 192.168.1.1Public side 49.36.100.20

How NAT Tracks Outbound Traffic

For a typical outbound IPv4 connection, the router replaces the private source address and port with its public address and another port. It stores translation state so returning packets can be mapped to the correct internal flow.

192.168.1.20:53124 -> NAT -> 49.36.100.20:62001 -> Internet -> Server:443

A second device can contact the same server through that public address because its translated source port differs. NAT maintains state associating each external flow with an internal endpoint.

What a Port Identifies

An IP address gets traffic to an endpoint. A port lets the operating system deliver transport traffic to the correct listening service. One server can expose HTTPS on TCP 443, SSH on TCP 22, and DNS on UDP or TCP 53.

Diagram 1

How Network Ports Select Services

The IP locates the endpoint; the destination port selects the listening service on that endpoint.
80 / 443
Conventional HTTP and HTTPS ports.
22
Common SSH administration port.
53
DNS over UDP or TCP.
5432
Common PostgreSQL port; normally kept private.
6379
Common Redis port; normally kept inside a trusted network.

Source and Destination Ports

A browser normally chooses a temporary source port while connecting to a known destination port. A flow might run from 192.168.1.20:53124 to 93.184.216.34:443. Replies reverse those endpoints, letting operating systems and stateful devices associate packets with the correct conversation.

Opening a firewall port does not create a service. A process must be listening, a route must exist, and every policy along the path must allow the traffic. Unexpected inbound traffic behind NAT may also require port forwarding, a tunnel, or a public intermediary.

Useful shorthand

The IP identifies the endpoint, the port identifies the transport service, and NAT rewrites and tracks endpoint information across address boundaries.

Series

How Internet Requests Actually Work

An eight-part beginner series tracing internet communication from an HTTP request through DNS, IP, ports, transport protocols, packets, network devices, server infrastructure, security, and troubleshooting.

Part 3 of 8
About the Author

Nikhlesh Yadav is a Technical Lead and Solution Architect with 12+ years of experience across cloud-native systems, distributed platforms, AI integrations, Web3, and cyber security.

Read full profile