Skip to content
Tutorials Center
My learning

Topics

Lesson 41 of 80 ยท Network Security

NAT, Proxies and Network Access Control

Learn how static, dynamic and PAT address translation works, the main proxy types and their security roles, and how pre-admission and post-admission network access control works.

Three building blocks appear on almost every organizational network diagram, and each is often misunderstood:

  • NAT (Network Address Translation) rewrites IP addresses as packets cross a router, so many private devices can share a few public addresses.
  • Proxies are intermediaries that make requests on behalf of someone else, which gives you a place to filter, log and cache traffic.
  • NAC (Network Access Control) decides whether a device or user may join the network at all, and what it may reach once connected.

None of them is a complete security solution on its own, but each contributes to a layered design. This lesson explains how each works, what security benefit it really offers (and what it does not), and uses small Python simulations of a translation table, a filtering proxy and an admission policy. It builds on Networking Essentials for Defenders and Firewalls, Segmentation and Zero Trust.

NAT: sharing and hiding addresses

IPv4 has only about 4.3 billion addresses, far fewer than the world's devices. Organizations therefore use private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) inside, and a router with a public address translates between inside and outside. NAT comes in three forms:

Type Mapping Use
Static NAT One private address always maps to one public address (1:1) Publishing an internal server so it is reachable from outside
Dynamic NAT A private address is mapped to one from a pool of public addresses on demand, then released Rare today; needs as many public addresses as simultaneous users
PAT / NAT overload Many private addresses share one public address, distinguished by port numbers Almost all home and office internet access

With PAT, the router keeps a translation table that records, for each outgoing connection, the inside address and port, the public address and a chosen outside port. Replies arrive for that outside port, and the router looks up the table to send them to the right inside host.

flowchart LR
    A["Laptop 10.0.0.5:50123"] --> R["NAT router<br/>public 203.0.113.10"]
    B["Phone 10.0.0.6:50123"] --> R
    R -->|"203.0.113.10:40001"| S["Web server 198.51.100.7:443"]
    R -->|"203.0.113.10:40002"| S

Two inside hosts used the same source port, so the router assigned different outside ports to tell the connections apart.

Python A PAT translation table

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

What NAT does and does not do for security

NAT is not a firewall. It is a side effect that, because the router has no mapping for unsolicited inbound traffic, such packets are dropped, so inside hosts are not directly reachable. This hides internal addressing and reduces casual scanning, but:

  • It does nothing to stop outbound connections from malware or botnets.
  • Port forwarding or static NAT deliberately opens a path in.
  • A compromised inside device can open a connection to an attacker, so the "protection" disappears.
  • It breaks some protocols that embed addresses (AH in IPsec, some voice and FTP modes) and complicates logging: all inside hosts share one public IP, so log the translations (or use flow logs) if you must trace an incident to one device (Logging, Log Analysis and SIEM).
  • IPv6 has enough addresses that NAT is not needed; protection must come from a stateful firewall.

Proxy servers

A proxy sits between a client and a destination. Because every request passes through it, it can authenticate users, filter, inspect, log and cache. There are several kinds:

Type Sits near What it does Security role
Forward proxy The clients Clients send requests to it, and it fetches them Enforce allow-lists, block malware sites, log browsing, data-loss checks
Reverse proxy The servers Accepts requests from the internet and forwards to back-end servers Hides back ends, terminates TLS, caches, load-balances, hosts a web application firewall
Transparent proxy The network path Intercepts traffic without client settings Enforcement without configuring devices (but cannot see inside TLS without inspection)
Anonymizing proxy / open proxy Anywhere Hides the client's IP address Used for privacy, but also by attackers; block open proxies
SOCKS proxy Clients Relays any TCP or UDP traffic General tunnelling, including SSH-based tunnels
TLS-intercepting proxy Network edge Decrypts, inspects and re-encrypts HTTPS using a company-trusted certificate Inspect encrypted traffic, with privacy and certificate-management costs

A forward proxy helps stop users from reaching malicious domains and gives central logs, while a reverse proxy protects your servers and is where you add rate limiting and a WAF (Project: A Mini Web Application Firewall). Proxies are also a risk: a misconfigured reverse proxy can be abused for SSRF (SSRF, Unsafe Deserialization and XXE), and a forward proxy that listens on the internet becomes an open relay. Also remember that the client IP seen by your application behind a reverse proxy is the proxy's; trust the X-Forwarded-For header only from your own proxy.

Python A forward proxy filtering by policy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The proxy gives one place to enforce policy and one log for investigations. The same idea scales to enterprise gateways, secure web gateways and cloud access security brokers.

Network Access Control (NAC)

A firewall guards a network's edge, but what about a visitor who plugs a laptop into a meeting-room socket, or an infected device that joins the Wi-Fi? NAC controls who and what may connect and what they may reach. It combines authentication, device checks and enforcement:

  • Authentication: the user or device proves identity, commonly with IEEE 802.1X: the device (supplicant) authenticates through the switch or access point (authenticator) to a RADIUS server (Kerberos, LDAP and RADIUS), using certificates or credentials. Devices that cannot do 802.1X (printers, cameras) are identified by MAC address or profiling, which is weaker because MAC addresses can be spoofed.
  • Posture assessment: is the operating system patched, is endpoint protection running and current, is disk encryption on?
  • Enforcement: the switch or controller places the device on the right VLAN or applies an access list: full access, a restricted guest network, or a quarantine network that can reach only the patch server.
  • Visibility: an inventory of every connected device.

NAC is usually described in two timings:

Pre-admission NAC Post-admission NAC
When Before the device gets network access After it is connected, continuously
Question "Who are you, and is your device healthy?" "Is what you are doing allowed right now?"
Examples 802.1X login, posture check, guest portal Re-checking posture, role-based access lists, quarantining a device that starts scanning
Strength Keeps unmanaged or non-compliant devices out Limits movement of a device that turns bad later

Combining both with segmentation and the zero-trust idea (never trust a device just because it is "inside") gives the best protection.

Python A NAC admission decision

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Practical cautions

  • Roll NAC out in monitor mode first, then enforce, to avoid locking out critical devices such as medical or industrial equipment.
  • Keep an exceptions process for devices that cannot authenticate, and isolate them in their own segments.
  • Fall-back behaviour matters: decide what happens if the RADIUS server is unreachable ("fail open" is convenient but unsafe; "fail closed" can cause outages).
  • Treat posture checks as a signal, not a guarantee, because software on a compromised device can lie.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which NAT type lets many private hosts share one public IP address?

    PAT distinguishes the connections by port number, so thousands of inside hosts can use a single public address.
  2. 2. Why is NAT not a substitute for a firewall?

    Dropping unmapped inbound packets is a side effect. Malware can still call out, and port forwards open paths in.
  3. 3. A server sits in a data center, and the proxy receives internet requests, terminates TLS and forwards them to it. What is this?

    A reverse proxy represents the servers to the outside world, hiding back ends and often hosting a WAF.
  4. 4. What distinguishes post-admission NAC from pre-admission NAC?

    Pre-admission decides who gets in; post-admission continues to enforce policy as behaviour or posture changes.

Summary

  • NAT rewrites addresses; static NAT maps 1:1, dynamic NAT uses a pool, and PAT shares one public IP using ports. It is not a firewall, and it complicates logging.
  • Forward proxies filter and log client traffic; reverse proxies protect servers; transparent, SOCKS, anonymizing and TLS-intercepting proxies serve other roles. Misconfigured proxies create risks such as open relays and SSRF.
  • NAC controls who and what connects (802.1X, posture checks, VLAN placement or quarantine) before admission and keeps enforcing after it.
  • Roll out NAC carefully, plan for devices that cannot authenticate, and decide the fail-open or fail-closed behaviour.

Next: Intrusion Detection and Network Monitoring.