Read a sample: 1. Why Networks Translate Addresses
A laptop on a small office network sends a request to a website. The laptop’s IPv4 address is 192.168.10.10, an address chosen for use inside the office. The website, however, cannot send a reply across the public internet to that private address. Somewhere between the laptop and the website, the packet needs an address that makes sense beyond the office network.
Network Address Translation, or NAT, provides a way to change address information as traffic crosses a network boundary. A router can replace the laptop’s private source address with an address used on the outside network, remember the relationship, and apply the corresponding translation to returning traffic.
That description is useful, but it leaves room for several important questions. What exactly counts as “inside”? Which address does the website see? How can multiple devices use one outside address? And if a translation exists, does that prove the destination is reachable?
This chapter establishes the vocabulary and the example network you will use throughout the book. The goal is not to memorize configuration commands yet. It is to understand the problem NAT addresses and to separate translation from the other jobs a network must perform.
An IPv4 address identifies an interface within an addressing scheme. For devices to communicate across interconnected networks, routers need addresses that can be used to make forwarding decisions. Not every IPv4 address, however, is intended to be routed across the public internet.
Three IPv4 blocks are reserved for private addressing:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
An organization can use addresses from these blocks within its own network without requiring those addresses to be unique across the entire internet. Another organization can independently use the same private addresses.
For example, two unrelated offices might each have a laptop at 192.168.10.10. That duplication is not inherently a problem while the addresses are used within separate private networks. It does mean that the address alone cannot identify one of those laptops uniquely across the public internet.
Public IPv4 addresses, by contrast, are used for communication on public networks and must be globally unique when publicly routed. Organizations obtain the right to use public addresses through appropriate allocation or assignment arrangements, often involving a service provider. Not every address outside the three private blocks is automatically suitable for ordinary public use; IPv4 also includes other special-purpose ranges.
The examples in this book use the documentation ranges 192.0.2.0/24 and 198.51.100.0/24 to represent outside addresses. These ranges are reserved for examples, not for real public internet connectivity. Treat them as stand-ins for usable public addresses in a lab or a diagram.
IPv4 has a finite address space. If every device on every private network needed its own globally unique public IPv4 address, the demand for public addresses would be much greater. NAT allows an organization to use private addresses internally while presenting one or more different addresses externally.
The amount of address conservation depends on the kind of translation used. A one-to-one mapping associates one inside address with one outside-facing address. That mapping is useful, but it does not let several inside devices simultaneously share that same outside address through a simple address-only mapping.
Port Address Translation, usually called PAT, extends the idea. For supported traffic such as TCP and UDP, PAT can distinguish concurrent conversations using port numbers as well as addresses. Many inside devices can therefore share a single outside IPv4 address for outbound communication.
NAT can also help an organization use one addressing scheme internally and another at a boundary. This book focuses on the common case of translating private inside IPv4 addresses to outside-facing addresses. NAT can be used in other arrangements, but learning this basic case first gives you a reliable foundation.
The important point is that translation changes information in a packet. It does not make the original private address globally routable.
Consider a small office connected through a router to an outside network:
text
Inside network Outside network
PC-A Web server
192.168.10.10 198.51.100.80
| |
| |
+---- 192.168.10.1 R1 192.0.2.2 ---- Outside network
|
NAT boundary router
Inside subnet: 192.168.10.0/24
R1 inside interface: 192.168.10.1
R1 outside interface: 192.0.2.2
Additional example translation addresses: 192.0.2.10–192.0.2.20
R1 connects the office’s inside subnet to the outside network. PC-A uses 192.168.10.1 as its default gateway. The web server is an outside destination at 198.51.100.80.
The diagram leaves out intermediate outside routers. Assume that appropriate routes exist when an example asks you to focus on translation. Later, you will examine what happens when that assumption is wrong.
The address 192.0.2.2 belongs to R1’s outside interface. Depending on the NAT configuration, R1 may use that interface address for PAT. The additional addresses 192.0.2.10 through 192.0.2.20 are available in the example addressing plan for other translation scenarios. Their presence in the plan does not mean R1 automatically translates traffic using them. Translation must be configured, and the surrounding network must be able to deliver return traffic for any translated address to R1.
Throughout the book, “inside” and “outside” describe roles relative to the NAT boundary. Inside is the side containing the addresses being translated in these examples; outside is the other side. These labels do not mean that one interface is physically indoors or that the outside network must always be the public internet.
Suppose PC-A sends a packet to the web server. Before translation, its IPv4 header contains:
text
Source: 192.168.10.10
Destination: 198.51.100.80
For this example, suppose R1 has an…