NAT Design on the Enterprise Network: PAT, Static NAT, Hairpin and Overlaps

How is NAT designed on an enterprise network? We cover NAT types, port exhaustion, reaching the external address from inside, overlapping subnets and rule order.
Technical summary
Technology
NAT, PAT, Twice NAT, SIP, Cisco IOS XE, Cisco ASA
Topic
Address translation design on the enterprise network
Level
Intermediate
Prerequisites
  • IPv4 addressing and subnet knowledge
  • Basic firewall/router configuration experience
In this article8 sections

Traffic to the branch doesn’t enter the tunnel, audio on the IP phone is one-way, and some users can’t open the company’s own website from inside. They look like three separate faults; the root of all three is often NAT design. In enterprise networks, NAT is usually considered “a setting turned on for internet access,” whereas address translation directly determines the reachability of published services, VoIP quality, the ability to connect networks in company mergers, and being able to find which device a connection came from during an incident investigation. Below we explain NAT types, PAT port exhaustion, choosing between hairpin NAT and split DNS, two-way NAT for overlapping subnets and NAT’s effect on application protocols with field scenarios.

NAT types and where they’re used

Classic NAT behavior is defined in RFC 3022. The types encountered on enterprise networks and the different terms vendors use for them:

Type What does it do? Typical use
PAT (NAT overload, masquerade) Many internal addresses → one/few public addresses, separated by port Users’ internet access
Dynamic NAT Internal address → a free public address from a pool, 1:1 Rarely; applications where port translation isn’t wanted
Static NAT (1:1) One internal address ↔ one public address, bidirectional DMZ server, VPN gateway
Port forwarding (DNAT, VIP) Public IP:port → internal IP:port Multiple services behind a single public IP
Twice NAT / policy NAT Source and destination together, conditional translation Overlapping subnets, business partner connections

On Cisco IOS, user egress is configured with ip nat inside source ... overload; on Linux, with masquerade or snat; on FortiGate, with NAT and IP pools in the firewall policy, and published services with a VIP object. The terms differ. The design questions are the same.

PAT and port exhaustion

PAT distinguishes sessions using the same public IP by source port number. The number of ports that can be used per protocol on a public IP address is about 64 thousand, in the 1024–65535 range. What matters isn’t the number of users but the number of concurrent sessions: browsers, cloud sync clients and update services open many connections at the same time.

Worked example: if an average of 60 concurrent TCP/UDP sessions per device was measured during busy hours on a network of 1,500 devices, the total comes to about 90 thousand sessions; a single public IP can’t carry this load, and a PAT pool of at least two, or three addresses with growth margin, is needed. Because the real value varies greatly from network to network, base the calculation on measurement.

Port exhaustion is an insidious fault, because its symptoms are random and temporary: some pages don’t load, the VPN client occasionally can’t connect, cloud applications give a “network error,” and five minutes later everything is fine. The user says “the internet keeps dropping”; the line is fine, the problem is in the NAT table. To check, monitor NAT statistics and the number of active translations, and review timeout values (long UDP timeouts in particular accumulate unnecessary entries). Endpoint-independent mapping behavior (RFC 4787) is recommended for application compatibility, but it limits the reuse of ports across destinations; be conservative in pool sizing.

The Cisco IOS XE example below defines a two-address PAT pool and a single static port forward (addresses from the documentation range):

interface GigabitEthernet0/0/0
 description WAN
 ip address 203.0.113.2 255.255.255.248
 ip nat outside
!
interface GigabitEthernet0/0/1
 description LAN
 ip address 10.10.0.1 255.255.0.0
 ip nat inside
!
ip access-list standard NAT-INSIDE
 permit 10.10.0.0 0.0.255.255
!
ip nat pool PAT-POOL 203.0.113.3 203.0.113.4 prefix-length 29
ip nat inside source list NAT-INSIDE pool PAT-POOL overload
ip nat inside source static tcp 10.10.20.15 443 203.0.113.5 443 extendable

For verification, show ip nat translations shows active translations, and show ip nat statistics the total number of translations and pool usage. Log NAT translations centrally: during an incident investigation, it’s the only way to get from a public IP and port to an internal device. No log, no trail. Confirm log retention obligations with the organization’s legal department.

Static NAT and port forwarding

There are two approaches for services to be accessed from outside. Static 1:1 NAT reserves a separate public address with all its ports for an internal server; the firewall policy determines which ports will be open. Port forwarding, on the other hand, distributes different ports of a single public address to different internal servers and is preferred when the number of public addresses is limited.

Points that can be missed in design:

  • Outbound traffic from a published server (for example, an email server’s SMTP egress) must leave from the same public address; otherwise inconsistency with reverse DNS and SPF records occurs and outgoing emails may be rejected on the other side. Static NAT provides this automatically; with port forwarding, a separate source NAT rule is needed.
  • In a dual-line setup, if a service is tied only to one carrier’s IP, the service becomes unreachable when that line goes down; the options for this situation are explained in the dual internet line article, and the permanent carrier-independent solution in the enterprise BGP multihoming article.
  • Keep published servers not in user VLANs but in a separate DMZ segment.

NAT hairpin and the split DNS alternative

When a user on the internal network reaches the company’s own web server by its public domain name, DNS returns the public IP. The packet goes to the firewall and is forwarded to the internal server with destination NAT. If the user and the server are on the same subnet, the server sends the reply directly to the user, bypassing the firewall because the source address is local; the connection can’t be established because the user receives the reply from an address it isn’t expecting. If the server is in a separate DMZ segment, the reply passes through the firewall anyway, and on most firewalls destination NAT applied to the internal interface is enough; the real problem is the same-segment case. Hairpin NAT (NAT loopback, U-turn) in this case translates the source to the firewall’s address along with the destination, so the reply returns through the firewall.

Hairpin works, but it passes internal traffic through the firewall unnecessarily, and in server logs all internal users appear to come from a single address. The cleaner alternative is split DNS: the internal resolver returns the internal IP and external DNS the public IP for the same name. The details of split DNS design are explained in the enterprise DNS architecture article.

Criterion Hairpin NAT Split DNS
Traffic path Turns around through the firewall Directly to the internal server
Source IP in the server log Firewall address The real user IP
Maintenance effort NAT rule Keeping two DNS records in sync
VPN/remote users An additional rule may be needed Depends on the DNS they use

Overlapping subnets: two-way NAT

Company mergers, business partner connections or machine vendors’ systems with fixed addresses often create situations where the same subnet is used on both sides. If both sides use 192.168.1.0/24, when a local device sends a packet to 192.168.1.10 on the other side, the packet stays in its own network. Even if the tunnel is up. The solution is for each side to present its own network to the other as a different “visible” subnet: side A presents itself as 10.200.1.0/24, side B as 10.201.1.0/24. A user at A reaches the server at B with the address 10.201.1.10.

In Cisco ASA (8.3 and later) syntax, the rule on side A is written as follows; on side B, the same structure is defined with the addresses reversed:

object network A-REAL
 subnet 192.168.1.0 255.255.255.0
object network A-VISIBLE
 subnet 10.200.1.0 255.255.255.0
object network B-VISIBLE
 subnet 10.201.1.0 255.255.255.0
!
nat (inside,outside) source static A-REAL A-VISIBLE destination static B-VISIBLE B-VISIBLE

In this structure, VPN traffic selectors and routing are defined with the visible subnets, not the real ones. DNS records, fixed IPs in application configurations and firewall objects should also be updated to the visible addresses. This is the part that can waste a lot of time: the NAT rule is correct, but the old real IP has been left in an application’s configuration file. For the design on the tunnel side, see the site-to-site IPsec VPN design article. Two-way NAT isn’t a permanent solution but a transition tool; in the long run, aim to rework the address plan.

NAT’s effect on SIP and other protocols

NAT changes only the IP and port headers; addresses embedded in application data stay as they are. This directly breaks some protocols:

  • SIP: SIP messages (Via and Contact headers and the SDP body) carry internal IP addresses. When the other side tries to send audio to this internal address, one-way audio occurs. The SIP ALG on the firewall tries to rewrite these addresses; if the PBX or SBC is also doing NAT correction, the two interventions conflict. The reliable method: configure NAT awareness on the PBX or SBC side, use rport (RFC 3581) and symmetric RTP, keep the registration and keepalive interval shorter than the firewall’s UDP timeout, and disable the ALG accordingly. With one-way audio, the first place to look is the address inside the SDP.
  • FTP: In active mode, the client announces its own IP and port for the data connection with the PORT command; behind NAT, without an ALG or inspection, it doesn’t work. Passive mode (PASV) solves most cases, but if the server is behind NAT, the server needs to be configured to announce its own public address.
  • IPsec: AH doesn’t work with NAT because it protects header integrity. ESP passes through NAT by being carried inside UDP 4500 with NAT-T.
  • Carrier CGNAT: On some lines (especially cellular), the carrier assigns an address from the RFC 6598 range (100.64.0.0/10) and applies a second NAT on its side; in this case inbound connections can’t be accepted. The topic is covered in the 4G/5G backup internet line article.

Scenario-based design table

Scenario Recommended NAT Watch out for
User internet egress PAT, an address pool if needed Measure the session count, log it
Web/email server Static 1:1 NAT, DMZ Outbound traffic from the same IP
Single IP, many services Port forwarding Don’t forget the source NAT rule
Access by public name from inside Split DNS (preferred), hairpin Keep the two DNS records in sync
Overlapping subnets Twice NAT Plan it as a transition tool
IP phones / SIP trunk PAT + NAT settings on the SBC/PBX Test the ALG decision
VPN between branches No NAT (NAT exemption) VPN traffic must not enter PAT

The last row points to a NAT mistake you may encounter: if the general PAT rule on the firewall matches before the VPN rule, traffic destined for the branch is translated to the public IP and never enters the tunnel. The tunnel shows “up,” but the counters don’t increase. Check the NAT rule order for every new tunnel. For the addressing and segmentation plan, see the VLAN, routing and network segmentation page; for the public address and line side, the internet line management page. If NAT mappings and access rules also change when switching to the backup line, test them under firewall installation and rule management.

Frequently asked questions

How many users can get to the internet with a single public IP address?

The limit isn’t the number of users but the number of concurrent sessions. A public IP address is limited to about 64 thousand ports above 1024 per protocol; the practical value varies with the application’s port reuse behavior. Measure the number of concurrent sessions from NAT statistics and size the PAT pool accordingly.

Should SIP ALG be disabled?

If the IP phones, PBX or SBC manage NAT themselves (with rport, STUN, registration refresh and symmetric RTP), SIP ALG should be disabled in most cases; the ALG rewriting SIP messages can cause problems such as one-way audio and dropped registrations. Make the decision together with the carrier’s and PBX vendor’s recommendation, by testing.

Is NAT a security measure?

NAT provides protection as a side effect because it hides internal addresses and unsolicited inbound connections can’t find a matching translation entry; but it wasn’t designed as a security control. Do access control with firewall policies, and design NAT only for addressing needs.

Won’t NAT be unnecessary after moving to IPv6?

Because every device can be given a global address in IPv6, NAT for address conservation isn’t needed; security is provided by the firewall. For special needs such as preserving internal addresses when changing carriers there’s NPTv6 (RFC 6296), but its use is exceptional. During the transition, NAT design on the IPv4 side remains valid.

Support

Contact us for support or a discovery session on this topic.

Contact form
[email protected]

Eretek Network

We build switching, routing, cabling and wireless networks with VLAN segmentation and redundant uplinks, and provide regular maintenance and fault support.

Knowledge Center

Other articles