Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 1: Networking Fundamentals

AWS Cloud

1.8 NAT (Network Address Translation)

Students in my class always ask: "Sir, my laptop shows 192.168.1.5, but Google sees a different IP. Why?" The answer is NAT. Come on, let's see how it works.

Hundreds of devices on a college network use private IPs, but the college may have only a few public IPs. NAT with port translation lets many private devices share one public IPv4 address in this design.

The router rewrites the source address of outgoing packets from the private IP to its public IP and keeps a translation table so replies go back to the correct device. The variant that also changes ports (many-to-one) is called PAT or NAT overload.

  Private LAN (192.168.1.0/24)                 Internet
 +------------------+
 | Laptop           |  src 192.168.1.10:50001
 | 192.168.1.10     |------+
 +------------------+      |      +-------------------+   src 192.0.2.70:61001
                           +----->|  NAT Router       |----------------------->  example.com
 +------------------+      |      |  Public 192.0.2.70|<-----------------------
 | Phone            |------+      +-------------------+   reply to 192.0.2.70:61001
 | 192.168.1.11     |               NAT table:
 +------------------+               192.168.1.10:50001 <-> 192.0.2.70:61001
NAT type Mapping Example
Static NAT 1 private ↔ 1 public (fixed) EC2 Elastic IP mapping to a private IPv4 while associated
Dynamic NAT private ↔ one from a pool of public IPs Enterprise routers
PAT / NAT overload Many inside flows share one or more outside IPs using ports Home Wi-Fi, AWS NAT Gateway

Ravindra Bagale's Tip

When designing a VPC, compare your CIDR with the networks that will connect to it. 192.168.0.0/16 can overlap common home and office networks. 10.20.0.0/16 can work when it is available in your plan. Choose carefully before connecting networks because changing addresses later can be a big job.

Ravindra Bagale's Tip

Many students think that because of NAT, anyone outside can reach their private laptop. In the outbound NAT example, the connection starts inside and translation state delivers its matching replies. An AWS public NAT gateway can help a private workload download updates. It does not accept new unsolicited internet connections to that workload. A separate public entry point uses its own routes and permissions.

Lab

On an approved Linux lab, compare ip -4 addr show with curl -4 --max-time 10 https://checkip.amazonaws.com if your network allows that check. The second command reports the outside source of its own request. Use example ports from the diagram to complete the mapping on paper, since these commands do not display the NAT table.

Got it? NAT translates addresses. This example also tracks port numbers so many devices can share one public IPv4. Now let's move on and see where all of this appears in AWS.

Give private computers a usable reply path to an outside service

Two Mauli Dairy office computers need to download the same vendor's inventory update. Their addresses are 192.168.45.25 and 192.168.45.26. Both are valid inside the office, where routers and switches know which network the addresses belong to. Outside organizations can independently use the same address numbers, so the vendor cannot send a reply over the public internet using either private address as its destination.

A translating router can make the reply path work. The office sends the request through that boundary. For the outward journey the boundary replaces the private source with an address that can receive a reply on the outside path. The destination service sends its reply to that outside address. When the same mapping is available at the boundary on the way back, the translator can deliver the reply to the original computer. Network Address Translation, or NAT, describes the change in address. In a common many-to-one IPv4 design, the translator also tracks or changes a transport port.

The office does not have to assign a separate public IPv4 to every laptop. Phones and laptops can keep their own addresses for printers, other permitted office communication and normal application work. The vendor's server continues processing the request without knowing the locally assigned address. It sees the source that reached it. If it recognizes users by an account and sign-in, that application behavior is separate from whatever source address the translation changed.

State means information the device keeps for a period. In the familiar outbound IPv4 case the translator keeps a mapping so replies can be associated with the correct inside traffic. A learner can think of the outbound packet as creating a return label at the boundary. That label is useful to the device that holds it. If a return path misses that device or the mapping has expired, the boundary may not have enough information to deliver the reply.

This chapter uses the two office addresses throughout. Values such as 203.0.113.20 and 198.51.100.70 represent the outer interface and vendor in a paper example. They are reserved documentation values. Work the addresses and ports by hand, or run the offline exercise with them. Use your actual approved endpoints only in an authorized training environment.

Build the request and return rows before looking at a router

The billing computer opens an HTTPS connection. It uses source TCP port 51042 to reach the vendor's destination TCP port 443. TCP is the transport protocol in this example, and a port lets each machine distinguish this connection from other traffic. A second computer can choose source port 51042 at the same time because it has a different local IP address. At that moment the two original connections are distinguishable by their source IP addresses.

Both packets now approach the same NAT boundary. If the translator used the same outside address and the same source port for these otherwise identical example connections, replies from that vendor could be ambiguous. In the worksheet the translator uses different outside ports. The exact selection varies by product and configuration. You could imagine that it preserves a port when possible and allocates another when needed. The point is that the reply lookup must have enough information to identify the expected inside flow.

Request identityOriginal sourceTranslated sourceDestination on the way outDestination inside on the way back
Billing TCP session192.168.45.25:51042203.0.113.20:62014198.51.100.70:443192.168.45.25:51042
Stockroom TCP session192.168.45.26:51042203.0.113.20:62015198.51.100.70:443192.168.45.26:51042

Read the first row in order. Before translation the source is the billing computer and its chosen port. After translation the source is the outside address and port 62014. The vendor replies from its server port to the address and port it saw. On return the translator uses the recorded mapping to rewrite that reply's destination back to the billing computer. The destination of an outgoing request stays the vendor in this example. When you draw arrows, move the translated pair to the destination column on the return arrow.

The second row explains why one public IP alone cannot identify a user. The vendor sees the same outside IPv4 for both connections. Its transport can still distinguish the response destinations, and the NAT can map them back separately. Because protocol, endpoints and time are relevant to interpreting the record, support teams should collect the precise approved observations needed for a diagnosis rather than circulate a raw request log or a customer's actual addresses.

The nickname PAT means Port Address Translation. The standards also use NAPT, for Network Address Port Translation. People often say NAT when they mean this familiar many-to-one translation. You can use the local term, then state whether the example changes an address only or also uses port mapping.

Identify whether the translator changes the source or the destination

Source NAT changes where a packet appears to come from. Destination NAT changes where the packet is sent. A translation can use one or both depending on the design. There is a simple way to recognize the first kind. The office's outbound request has the same intended vendor destination on both sides. The difference is in the source IP and possibly its source port. For the reply, the translator performs the corresponding reverse operation on the destination.

Now imagine a documented inbound service operated by the office. Someone authorized to maintain the network has arranged for a connection to its approved outside listener to be delivered to an internal endpoint. For a destination translation example, a new connection to an outside address and port would be written to the appropriate inside address and port. That delivery is a separate design decision. An ordinary outbound-only translation mapping does not create a public entry for that service. A permitted target still needs a listener and the appropriate firewall policy. A different design might terminate the connection at a public proxy instead, creating a new backend connection through the proxy.

Address-only translation can be useful when the mapping is a fixed pair. A simple one-to-one example can associate an external address with one internal address and leave the port as it is. Dynamic address-only tradeoffs arise when there is a pool of outer values to allocate temporarily. Port translation enables several inside connections to share an outer address in the common examples. The right worksheet describes the actual mapping and duration. “It uses NAT” alone leaves those choices unspecified.

In cloud discussions, be precise about which component owns each change. An AWS internet gateway performs the public-to-private IPv4 mapping for an instance with a public IPv4 association. When a private instance goes out through a public NAT gateway, the public IPv4 belongs to the NAT path, not the instance. An internet-facing load balancer accepts client traffic and can send a separate connection to its target. These tools can appear in one design. They have different entry conditions and different places to check when a request fails.

Define the application requirement before choosing a model. A vendor that wants its clients to use a stable observed source has an egress requirement. A customer who needs to open a public tracking website has an ingress requirement. An internal printer that users access within the office can stay on its ordinary private path. The path direction is the fastest way to start reasoning about which change, if any, belongs in the design.

Follow a mapping through creation, reuse and expiration

A packet that begins a valid outbound flow can cause a mapping to be recorded. Subsequent matching traffic can use that mapping. When a tracked connection ends, or when traffic is absent for the limit that applies to the device and protocol, the device can remove the state. The outside address remains present but that particular return association is no longer usable. Later connections can receive newly allocated state. Save the distinction between an address that exists and a flow entry that exists.

TCP keeps its own connection state and has known steps for starting and closing a connection. A translator can track what it observes and apply its timer rules. UDP has no TCP-style connection setup and teardown. A translator can still keep a temporary mapping for UDP exchanges using the protocol and visible endpoints. A DNS query sent over UDP can receive a reply during the life of that mapping. It would be a mistake to say that UDP can never be translated because UDP does not form a TCP connection.

Suppose the vendor's request path worked at 09:00, the application kept a connection idle in a pool, and its next use failed at 09:20. A connection pool helps an application reuse existing connections rather than creating one for every operation. It has to cope with the possibility that a connection recognized in application memory no longer works across the network. AWS documents an idle timeout for NAT gateway connections. The relevant diagnostic is to compare fresh connections with reused ones, review idle timeout observations and check application behavior for reconnecting.

At the next layer, a failure during a repeated read is different from a failure during a write. If a read of inventory status is retried, the main concern is getting a fresh successful result. If the client submits a payment and the response doesn't return, the server might have processed the payment before the path failed. The application needs a supported way to check the prior outcome, or an operation identifier that makes repeat submission safe. Network retry behavior alone cannot establish whether a business operation already took effect.

For a managed NAT gateway, the team uses approved service metrics and scoped application logs instead of assuming it can open an interactive session on the gateway. In a lab model, you can show expiry by removing one row. In a real network, node and service settings determine how state survives changes. A failover may provide a path for new traffic while existing connections still need to reconnect. Record requirements for both when discussing availability.

Trace both translations in a zonal public AWS NAT gateway path

Place a worker at private IPv4 10.40.20.25 in a Mauli application subnet. It needs to fetch an authorized HTTPS resource. It has no direct public IPv4. Its subnet's route table sends the relevant internet-bound IPv4 traffic to a public NAT gateway in the zonal availability mode. For this design, the zonal gateway sits in a public subnet. That subnet's route table has the necessary route to the VPC's internet gateway. The NAT gateway has a private IPv4 and a public Elastic IP association.

  1. The worker resolves the provider's name and sends its packet. The private subnet's route lookup chooses the NAT gateway for the vendor address unless a more specific route sends it elsewhere. A VPC-local route or an endpoint route should remain valid for destinations it specifically covers.

  2. The public NAT gateway maps the worker's private source to the NAT gateway's private address, applying the relevant translation state. The worker interface continues using its original private address.

  3. On the internet path, the internet gateway maps the NAT gateway's private IPv4 to its associated Elastic IP. The vendor sees the resulting internet-side source. The vendor does not see the worker's private source, and the worker hasn't acquired a public address of its own.

  4. The provider sends its reply to the outside source it observed. The internet gateway and NAT gateway reverse their parts of the translation. The returned packet is delivered to the worker's local connection if the path and policy permit it.

Notice which route belongs to each subnet. The app subnet points to the NAT gateway for this IPv4 egress. The public subnet hosting the zonal NAT gateway points at the internet gateway for the outward path. Viewing the route table with a particular name is not enough. Confirm the associations, since an instance uses the route table assigned to its own subnet or the VPC's main table if no explicit association applies.

With appropriate access controls, policy on the app instance permits the expected egress and the matching replies. Security groups attach to supported resources such as the instance, and you cannot associate one directly with the NAT gateway. Review any relevant subnet network ACLs, which evaluate incoming and outgoing traffic separately. Do not assume that all outside access belongs to this path. An HTTPS connection from a customer to the tracking load balancer and a return connection through the NAT gateway are different flows and may use different components.

If your task requires reaching a connected private destination rather than the public internet, identify the translation and route that apply there. For example, on a private path through a transit gateway or virtual private gateway, a public NAT gateway can present its private IPv4 source. Its Elastic IP is the source for the associated internet gateway path, not a blanket source for every packet it handles.

Choose an egress pattern that matches the destination and availability need

Before making a cost or availability estimate, ask who decides where a new connection starts, which destinations it may use, and what must keep working if one zone has a problem. A zonal gateway is tied to an Availability Zone. AWS recommends using a zonal gateway in each relevant zone with routing to the same-zone gateway when using that mode for a multi-zone workload. This avoids making otherwise separate application subnets depend on a single NAT zone for their outbound path.

A regional public NAT gateway uses a different model. It has its own route table and does not require a public subnet to host it. Workload routes can point to one regional gateway ID. AWS documents how it can extend to zones as workloads are detected, depending on the configured IP address management mode. Check availability, behavior during expansion, address management and the current pricing for the intended zones. A regional gateway does not support private NAT. A team migrating from an older zonal pattern should examine how the source addresses will change before switching routes.

RequirementCandidate AWS pathVerification before choosing it
Private IPv4 workloads need selected public IPv4 destinations.Public NAT gateway in an appropriate mode, with the required route to the internet.Actual subnet and gateway routes, costs, supported zones, expected outside addresses and egress controls.
Private IPv4 workloads need a translated address for a connected private destination.Zonal private NAT gateway and approved private routing, if the use case fits.The destination route, address plan, reachability from the translated private address, and policy on both sides.
A private workload needs an AWS service such as Amazon S3.A supported VPC endpoint for that service.Endpoint type, route or DNS configuration, Region, service policies and permissions.
IPv6 clients need to reach IPv6 internet services through an outbound-only path.An egress-only internet gateway for suitable IPv6 traffic.IPv6 addressing, IPv6 routes and policy. IPv6 to IPv4 needs a separate design.
IPv6-only workloads need a compatible IPv4 destination.DNS64 and NAT64 where supported for the required path.Resolver behavior, IP family of the target, translation route and destination access controls.

The IPv6 row is worth reading twice. An egress-only IPv6 internet gateway provides the outbound-only use case for native IPv6 routes. It does not turn an IPv4 server into an IPv6 endpoint. DNS64 and NAT64 are tools for connecting different address families. Review the actual service rather than adding an IPv4 NAT path simply because a worker is called private.

A NAT instance is a different implementation in which the customer maintains an EC2 machine acting as the translator. That owner takes on the scaling, software updates, failover configuration and operating tasks for the instance. AWS documents how the instance and gateway modes differ. For an introductory design decision, paper out operations, availability and cost alongside the routing pattern. An apparently simple gateway box on the diagram still represents service responsibility somewhere.

Plan the connection budget and policy before adding routes

A central egress address helps when a vendor asks which office source it should allow. It concentrates traffic, which also concentrates some operational limits. Many workers can open connections toward the same destination at the same time. An increase in workers, unnecessary new connections or a very large number of idle connections can consume state even if total network throughput looks modest. Check the NAT gateway's relevant connection and port allocation metrics along with actual application connection behavior.

Capacity depends on source addresses, destination identity, protocol and product rules. AWS documents a limit per NAT gateway IPv4 address and unique destination tuple. A destination tuple includes the destination address, destination port and protocol as AWS defines it. Capacity analysis should use the current docs for the selected mode and your real connection pattern. Application teams can consider reusing healthy connections, setting appropriate idle behavior, spreading load or allocating additional approved egress capacity where documented. Reopening every connection without diagnosis can deepen the concentration.

Cost has moving parts. AWS pricing includes NAT gateway hours and per-volume processing charges. AWS counts regional gateway hours for each Availability Zone where it is configured. For example, one clock hour across three active zones represents three gateway hours under that model. The gateway ID count and the billable gateway hours describe different things. Data transfer and public address charges may also apply. A zonal design that sends traffic across an Availability Zone boundary may have costs and dependencies that the same-zone diagram avoids. Use actual account inventory, the current Region's pricing and a reasonable data estimate. Do not promise a fixed charge or that a lab costs nothing. Emptying the workload is separate from removing the egress resource left behind.

Access policy belongs in the design as well. The workload should have permission only for the destinations and operations that belong to its role under its organization's controls. Application credentials, encryption, network policy and identity still matter after a source address is translated. Source translation can hide the original interface number from a vendor while still carrying a sensitive application request. Store credentials in the approved system and use a legitimate service endpoint with the expected certificate. A shared address is an attribute of the connection, not an application identity.

Run a table lookup for two replies and an expired mapping

You need Python 3 and a shell. This exercise keeps rows in an ordinary dictionary and prints pretend packet destinations. It does not open sockets, route packets, consult a real device or change the system. Write down which office client should receive each reply before running it. The model uses a key made of protocol, external address and port, and peer address and port. Real translators have their own mapping, connection tracking and filtering rules.

python3 - <<'PY'
outer_ip = "203.0.113.20"
vendor_ip = "198.51.100.70"

billing = ("TCP", outer_ip, 62014, vendor_ip, 443)
stock = ("TCP", outer_ip, 62015, vendor_ip, 443)

replies = {
    billing: ("192.168.45.25", 51042),
    stock: ("192.168.45.26", 51042),
}

def show_reply(label, key):
    target = replies.get(key)
    if target is None:
        print(f"{label}: no matching mapping")
        return
    address, port = target
    print(f"{label}: deliver to {address}:{port}")

show_reply("Billing reply", billing)
show_reply("Stock reply", stock)
show_reply("Different protocol",
           ("UDP", outer_ip, 62014, vendor_ip, 443))
show_reply("Untracked incoming traffic",
           ("TCP", outer_ip, 63000, vendor_ip, 443))

del replies[billing]
show_reply("Billing reply after expiry", billing)
show_reply("Stock reply after expiry", stock)
PY

The first two lines should show delivery to different private addresses. Their local source ports happen to be equal, but the return keys use different outer ports. The third line has a different protocol, so the example's matching rule cannot reuse the TCP row for UDP. The fourth line picks an untracked external port and should report no mapping. Removing the billing row causes the old billing reply to miss, while the stock row still matches. No network interface or real connection changed as a result of this removal.

Now alter the example on paper. Add a third computer that requests the same vendor using TCP. Give it the same local port and its own local address. Pick an unused external port for the illustrated key. Explain why the vendor can reply to all three open connections. Then change only one factor in a return request. Choose the destination port at the external address or the transport protocol. Predict its lookup result before changing the script.

If the sample fails with a Python indentation error, check that the function body and conditional body have the shown indentation. If your terminal doesn't interpret the shell heredoc syntax, start Python interactively or put the Python statements in your own scratch file. The responses are local printouts. A failed lookup in the script says something about that dictionary and gives no information about actual internet reachability.

Finally, explain which detail the model hides. It builds both rows in advance instead of watching handshake packets and allocating outside ports. It also combines address lookup and the example's expected peer in one table. Keeping those implementation limits in mind makes the worksheet useful when an interview asks you to describe the concept. You can describe what has to match for the example while leaving room for different NAT devices to implement supported behaviors differently. Remove the scratch file if you created one. There are no AWS resources to clean up.

Audit the two subnet routes on an already approved AWS lab

This optional inspection needs an existing training VPC with a private test worker and a zonal public NAT gateway. Use a read-only console session if appropriate. Confirm the account, Region, exact test resource and your permission to inspect it. If you have no suitable AWS account, fill in the same worksheet from the topology in this chapter. The lab does not ask you to create or delete a resource, change access policy or enable a new diagnostic service.

  1. Find the worker's interface and subnet. Record its private IPv4 and whether it has its own public IPv4. Existing test environment results should match the chosen example. A worker with a public association could instead have a direct path under a different route configuration, so document what you actually find.

  2. Open the route table that applies to that subnet. Check whether the vendor's chosen IPv4 would match a more specific route before the default. If the route points to the NAT gateway, write its identifier. In a worksheet use the diagram label instead of real IDs. A route to an endpoint, a private attachment or a different next hop means the request may bypass this NAT gateway.

  3. Inspect the selected gateway's state and mode. For the zonal public case in this exercise, identify the gateway's subnet, intended Elastic IP and Availability Zone. Look up the route table that applies to its subnet and confirm that it has the needed internet gateway route. For a regional gateway in an actual environment, use its mode-specific route table and Availability Zone information rather than pretending it lives in the zonal gateway's public subnet.

  4. Within the existing permissions of the approved private worker, ask the designated lab owner for the observed source of one request to an approved IPv4 HTTPS endpoint. If the account already allows the AWS address observation endpoint, the command below performs one bounded read. Confirm the result belongs to the selected public NAT path's addresses. You can do this part using the supplied lab output instead of making a new request.

    curl -4 -f --connect-timeout 5 --max-time 10 https://checkip.amazonaws.com
  5. Write one line for each boundary. The guest interface shows the worker's private source. The NAT path has the appropriate mapping. The remote HTTPS server sees the outside source that reached it. Keep actual addresses private in your training records and use example values in shared screenshots.

If DNS lookup fails, check the name and resolver path rather than using the failure to judge NAT reachability. If the address resolves and the connection times out, confirm routes, gateway state and authorized workload policy. If the request works and the address differs from your worksheet, check whether the worker is using a proxy, a different gateway, or a mode with several available public addresses. Avoid widening the permitted destination or changing the gateway simply to force a matching output.

The read-only lab leaves existing resources alone. For a disposable build owned by your training session, follow the separately approved cleanup plan. Identify affected routes before removal, check that no other workload depends on the gateway, and then verify which addresses and other named resources your lab created and retained. Delete or release only resources your account's instructions mark as disposable. AWS notes that a route targeting a deleted NAT gateway becomes a blackhole until the route is changed or removed. A gateway deletion and a billable address release are separate lifecycle questions.

Diagnose which boundary failed instead of changing every route

Mauli releases a new worker in another Availability Zone. It can process database reads over the private VPC path, but a vendor HTTPS request fails. One old worker still reaches the vendor. The incident report already narrows the scope. Some local communication works. The public or private vendor path differs from the database path. An older worker's success gives you an approved comparison for checking what changed.

  1. Confirm that the failing worker and old worker request the same name, address family, service port and expected operation. Read allowed application evidence for whether they hit the same destination. A deployment could use a new DNS name that lands on a different network, so the endpoint itself is part of the comparison.

  2. Trace both worker subnets toward that destination. Inspect specific routes before default routes, then check the target state and route tables for the selected mode. This catches a new subnet associated with a training or main route table that omits the expected egress route.

  3. Ask whether a vendor allowlist contains the source addresses actually used in the new zone. A single approved egress from one zone does not prove that a new zone uses the same external source. Have the approved network owner compare the paths and the vendor confirm the expected account and address. A correct route with an unrecognized source can still lead to a rejected operation.

  4. Compare managed NAT metrics and application timing around the problem. An idle-reuse problem can show up as fresh requests succeeding and later reuse failing. Connection allocation errors can appear under concentrated bursts. A missing route normally affects the path even before application traffic rises. These patterns suggest different next checks rather than one universal fix.

  5. Repeat the intended HTTPS check from the known failing environment after an approved correction. Record DNS, selected address, connection outcome, source observed at the endpoint if available and useful application response. This result is stronger than a successful ping, which exercises a different protocol and may be intentionally unavailable.

If the same worker reads the vendor service successfully but customers cannot reach the tracking website, switch diagrams. The vendor connection began inside the application network and uses egress. The customer's first connection belongs to the public frontend. Confirm the frontend's name, listener, target health and policy. Work on the path the caller needs. A healthy NAT gateway is useful evidence about its role but cannot make an unrelated public listener available.

Practice decisions about translations, endpoints and costs

  1. Fill in the vendor's reply tuple for the stockroom flow. Your answer should identify the vendor as the source, the selected outer address and port as the destination, and TCP as the protocol. Show the new destination pair the boundary uses on the inside. Check that you did not accidentally change the origin of the reply to the client.

  2. Mauli's archive writer must upload to S3 and also call an external provider when a shipment is ready. Draw two outbound paths from the app subnet. Name the AWS service destination that could use an endpoint and the external destination that may still use public NAT. Mark where service identity and relevant status checks belong. Explain why deleting the default route without checking the second path can stop part of the workflow.

  3. A team with workloads in two zones wants to use one regional public NAT gateway ID. Write a release checklist for each affected vendor. Provide an expected source address record for the actual address management mode, a permitted request, a test after adding a zone and an estimate of gateway and processing usage. Explain which current AWS docs you would check before changing production routes.

  4. A company has ordered a small private test environment for one day and wants to finish without continuing resource charges. Identify the training workload, route references, logs or retained infrastructure, gateway and addresses separately. For each item write whether it belongs to the lab or someone else, and what evidence establishes retention or cleanup. A successful plan protects shared resources and has a way to verify completion.

Interview questions and worked answers

What problem does PAT solve when two computers choose the same local source port?

The two original connections have different internal source IP addresses. If they share an outside address and contact the same server port, the translator can allocate distinct outside ports and keep mappings. The server replies to each observed source pair. The translator uses its state to deliver the replies to the correct client and local port.

Why does receiving a reply not create a public listener for the worker?

A reply matches the expected translation for a flow started by the worker. A new unsolicited internet connection would need its own permitted inbound design and an appropriate listener. The managed NAT gateway in this example supports the outbound-initiated path, while customer-facing entry would normally use a distinct public endpoint.

Where does the source address change on the zonal public gateway path?

The NAT gateway maps the workload's private source to the gateway's private IPv4. The VPC internet gateway maps the gateway's private IPv4 to its associated Elastic IP on the public path. Reply traffic follows the inverse mappings. A connected private path can expose a different translated source, so include the destination's route in the answer.

Why can AWS regional and zonal gateways have different diagrams?

A zonal public NAT gateway is hosted in a public subnet in one Availability Zone. The regional public NAT gateway uses its own route table and can serve multiple zones with one gateway ID, with expansion and address behavior depending on configuration. Private NAT is a zonal choice. Pick one mode before writing the intended route sequence or budgeting its resources.

When would you put a VPC endpoint in a NAT discussion?

If the only required destination is a service that provides a compatible VPC endpoint, that connection can use the endpoint path under its route, DNS and policy rules. A gateway endpoint for supported S3 access is a common example. Check the rest of the workload separately. An endpoint for one AWS service does not carry all general internet traffic.

Why might an application work on a fresh connection after a reused connection failed?

The old flow's network state could have expired while the application's pool still held the connection. A newly initiated flow can establish current state. Compare the timing, relevant NAT service metrics and the application's connection pool behavior. For writes, confirm the earlier outcome using the application's safe retry mechanism before submitting the action again.

Check which address and path the reply needs

  1. Two office workers choose the same TCP source port to the same vendor. What makes the illustrated replies distinguishable on return? A. A different external source port per connection. B. A different Ethernet address visible to the vendor. C. An identical external source pair.

    Show answer

    A. In this example the outside address is shared and the destination is identical, so the translated ports distinguish the replies. Internal Ethernet details are local to their respective links and do not serve as the vendor's destination identity. Identical outside tuples would be ambiguous for these example flows.

  2. The private worker reaches HTTPS through a zonal public NAT gateway. Which address does the outside vendor receive? A. The worker's private address. B. The NAT gateway's public Elastic IP for the internet path. C. The subnet's network number.

    Show answer

    B. The NAT gateway maps the worker's source to the NAT private IPv4. The internet gateway maps that source to its associated Elastic IP on the public path. The worker keeps its private address. A subnet network number describes an address block, not the identity of a connection.

  3. A newly created private IPv4 worker needs access only to compatible S3 storage in its Region. Which path is worth checking before adding a general NAT route? A. An S3 VPC endpoint. B. An egress-only internet gateway for IPv4. C. Giving the database a public address.

    Show answer

    A. A supported endpoint lets the private workload access the service using the endpoint's routes and policies. The operation also needs valid AWS permissions. The egress-only internet gateway case applies to IPv6, and a public database does not provide the S3 service path.

  4. Which gateway choice can use its own route table without a hosting public subnet in the model described? A. Every NAT gateway mode is identical. B. Regional public NAT gateway. C. Zonal private NAT using an Elastic IP.

    Show answer

    B. AWS's regional public NAT gateway uses its own route table and does not need a hosting public subnet. The zonal public example needs a public subnet and direct internet gateway path. Private NAT does not take an Elastic IP and does not receive an internet path by pointing it at an internet gateway.

  5. A new connection succeeds, but reusing a long-idle connection sometimes fails. What should you examine first? A. Whether old flow state expired and how the application reconnects. B. Whether the office allocated a new RFC 1918 block. C. Whether opening a public inbound listener will repair it.

    Show answer

    A. Compare the application timestamps, fresh and reused connections, and relevant NAT idle behavior. Established flow state can be gone by the time an old application connection is used again. An unrelated address plan or inbound listener does not explain the fresh-versus-reused evidence.

Revision cards

Original source
The inside address and transport port used before the boundary. In the example the caller retains that configuration throughout.
Translated source
The source sent on the outside path. A vendor replies to this observed address and port.
Return lookup
For an ordinary outbound translation, an expected reply uses an active association to find the inside destination.
Zonal public NAT gateway
Private subnet traffic can route to the gateway in a public subnet, and the internet gateway supplies the associated public side of the IPv4 mapping.
Regional public NAT gateway
The gateway has its own route table and can provide regional availability with mode-specific IP address behavior. Use zonal mode for private NAT.
Endpoint alternative
Where supported, a VPC endpoint can provide a destination-specific private path. Check the specific service, routing or DNS behavior, and permissions.

References