What Happens When You Open a Website? — Part 4
Part 4: How Your Packet Leaves Your Network: Gateway, Routing, and NAT
What Happens When You Open a Website? — Part 4
Part 4: How Your Packet Leaves Your Network: Gateway, Routing, and NAT
In Part 3, we stopped at an important moment:
Your computer knows:
- The website’s IP address (from DNS)
- The MAC address of your router (from ARP)
Your computer has built the Ethernet frame:
Ethernet Frame
Destination MAC:
Router's MAC address
Source MAC:
Laptop's MAC address
--------------------------------
IP Packet
Source IP:
192.168.1.10
Destination IP:
142.250.x.x
The packet is ready to leave your device.
But a new question appears:
Why does the packet go to the router first? Why can’t my laptop directly send it to Google’s server?
The answer involves three important concepts:
- Default Gateway
- Routing
- Network Address Translation (NAT)
1. Local Network vs Internet
Before sending a packet, your computer first decides:
“Is the destination inside my local network or outside my network?”
Imagine your home network:
Laptop:
192.168.1.10
Router:
192.168.1.1
Phone:
192.168.1.20
All these devices belong to the same network:
192.168.1.x
If your laptop wants to communicate with your phone:
Laptop
192.168.1.10
↓
Phone
192.168.1.20
The communication stays inside the LAN.
The laptop can directly use ARP:
Who has 192.168.1.20?
Phone replies:
My MAC address is XX:XX:XX:XX:XX:XX
No router is needed.
But now you want to open:
google.com
↓
142.250.x.x
Your laptop checks:
Is 142.250.x.x part of my network?
No.
Google is outside your LAN.
Your laptop needs another device to send the packet out.
That device is the default gateway.
2. What Is a Default Gateway?
A default gateway is the device your computer sends packets to when the destination is outside the local network.
In most homes:
Default Gateway = Router
Example:
Your laptop network settings:
IP Address:
192.168.1.10
Subnet Mask:
255.255.255.0
Default Gateway:
192.168.1.1
This means:
“For anything inside my network, send directly. For everything else, send it to 192.168.1.1.”
Your router acts as the door between:
Your Home Network
|
|
↓
Internet
That is why it is called a gateway.
3. How Does Your Computer Decide Where to Send?
Your computer uses a routing table.
A simplified routing table looks like this:
Destination Action
192.168.1.0/24 Direct delivery
0.0.0.0/0 Send to 192.168.1.1
The first rule means:
“Devices inside my network can be reached directly.”
The second rule means:
“Anything else goes to my default gateway.”
The 0.0.0.0/0 entry is called the default route.
4. ARP Finds the Gateway MAC Address
Your laptop knows:
Google IP:142.250.x.x
Default Gateway:192.168.1.1
But Ethernet does not use IP addresses.
It needs a MAC address.
So your laptop asks:
ARP Request:
Who has 192.168.1.1?
The router replies:
ARP Reply:192.168.1.1 is my IP
My MAC address is:AA:BB:CC:DD:EE:FF
Now your laptop can create the Ethernet frame:
Ethernet Frame:
Destination MAC:
AA:BB:CC:DD:EE:FF
Source MAC:
Laptop MAC
IP Packet
Source IP:
192.168.1.10
Destination IP:
142.250.x.x
The packet reaches the router.
5. The Router Receives the Packet
The router receives the Ethernet frame.
First, it checks:
Destination MAC:
AA:BB:CC:DD:EE:FF
Since this is its own MAC address, it accepts the frame.
Then it removes the Ethernet header.
Inside, it finds:
IP Packet
Source IP:
192.168.1.10
Destination IP:
142.250.x.x
Now the router asks:
“Where should I send this packet next?”
It checks its routing table.
6. The Problem With Private IP Addresses
The router wants to send this packet to the Internet.
But there is a problem.
The source IP is:
192.168.1.10
This is a private IP address.
Private IP ranges include:
10.x.x.x
172.16.x.x - 172.31.x.x
192.168.x.x
These addresses work only inside private networks.
They cannot be routed across the public Internet.
Why?
Because millions of devices can have the same private IP.
Example:
Home A: 192.168.1.10
Home B: 192.168.1.10
Company: 192.168.1.10
If Google received:
Source IP: 192.168.1.10
it would not know which network sent the request.
This is where NAT solves the problem.
7. What Is NAT?
NAT stands for:
Network Address Translation
NAT is a process performed by your router that changes private IP addresses into a public IP address before sending traffic to the Internet.
Your ISP gives your router a public IP.
Example:
Router Public IP: 49.36.x.x
Before NAT:
IP Packet
Source IP: 192.168.1.10
Destination IP: 142.250.x.x
After NAT:
IP Packet
Source IP:49.36.x.x
Destination IP:142.250.x.x
Now the packet can travel across the Internet.
8. What Does Google See?
Google does not see your laptop’s private IP.
Google sees:
Source IP: 49.36.x.x
Destination IP: 142.250.x.x
From Google’s perspective:
“A device with public IP 49.36.x.x requested this webpage.”
Your internal address:
192.168.1.10
never leaves your home network.
9. How Does the Router Know Where Replies Should Go?
Suppose you have many devices:
Laptop: 192.168.1.10
Phone: 192.168.1.11
TV: 192.168.1.12
All of them use the same public IP:
49.36.x.x
When Google sends responses back, how does the router know which device should receive them?
The router keeps a NAT table.
Example:
Private Address Public Address
192.168.1.10:5000 ---> 49.36.x.x:6000
192.168.1.11:5001 ---> 49.36.x.x:6001
192.168.1.12:5002 ---> 49.36.x.x:6002
The router uses port numbers to track connections.
When a reply arrives:
Destination: 49.36.x.x:6000
The router knows:
Send it to: 192.168.1.10:5000
10. The Packet Travels Across the Internet
After NAT, the packet looks like:
Source IP: 49.36.x.x
Destination IP:142.250.x.x
Now it enters the Internet.
The journey:
Your Laptop
↓
Home Router
(Default Gateway)
↓
ISP Router
↓
Regional Router
↓
Backbone Router
↓
Google Network
↓
Google Server
Every router performs the same basic process:
- Receive packet.
- Read destination IP.
- Check routing table.
- Choose the next hop.
- Forward the packet.
11. What Changes at Each Router?
This is very important.
MAC Address
Changes at every hop.
Example:
Laptop MAC
↓
Home Router MAC
Then:
Home Router Mac
↓
ISP Router MAC
Then:
ISP Router MAC
↓
Another Router MAC
MAC addresses are only for local delivery.
IP Address
Normally stays the same end-to-end:
Source IP: 49.36.x.x
Destination IP:142.250.x.x
However, NAT changes the source IP at the boundary between your private network and the Internet.
12. What About TTL?
Every IP packet contains a field called:
TTL (Time To Live)
TTL prevents packets from looping forever.
Example:
TTL = 64
Every router decreases it:
64
↓
63
↓
62
↓
61
If TTL reaches zero, the packet is discarded.
Final Picture
The complete journey:
Browser
↓
DNS
Find Google's IP
↓
ARP
Find Router MAC
↓
Default Gateway
Send packet to Router
↓
NAT
Private IP becomes Public IP
↓
Routing
Routers forward packet
↓
Google Server
Key Concepts to Remember
Default Gateway
The router your device uses to leave the local network.
Routing
The process routers use to decide the next path for a packet.
NAT
The process that converts private IP addresses into a public IP address so devices can communicate with the Internet.
MAC Address
Used only for the next local hop.
IP Address
Used for end-to-end communication.
Conclusion
Your first packet has now successfully left your home network.
The computer solved three important problems:
DNS solved:
Website Name → IP Address
ARP solved:
Gateway IP → Gateway MAC Address
NAT solved:
Private IP → Public IP
Routing solved:
How the packet reaches the destination network
The packet is now traveling across the Internet toward the web server.
But before the browser can exchange actual webpage data, it needs to create a reliable connection with the server.

Useful Commands (Windows)
1. View Your Default Gateway
You can view your IP configuration, including the default gateway, using:
ipconfig
This shows information such as:
- Your IPv4 address
- Subnet mask
- Default Gateway (your router)
Example:
IPv4 Address . . . . . . . . : 192.168.1.10
Subnet Mask . . . . . . . . .: 255.255.255.0
Default Gateway . . . . . . .: 192.168.1.1
2. View the Routing Table
You can see how Windows decides where to send packets using:
route print
This displays your system’s routing table, including:
- Directly connected networks
- The default route (0.0.0.0/0)
- The default gateway used for destinations outside your local network
3. Trace the Path to a Website
To see the routers your packet passes through on its way to a website, use:
tracert google.com
This shows:
- Each router (hop) between your computer and the destination
- How packets travel across multiple networks before reaching the server
4. View Your Public IP Address (NAT)
To see the public IP address that websites see (after NAT), use:
curl ifconfig.me
This shows:
- Your router’s public IP address
- The IP address that is visible on the Internet after Network Address Translation (NAT)
In Part 5, we will explore the TCP Three-Way Handshake and understand how your browser establishes a connection before downloading the webpage.
메타데이터
- post_id
- ddc82ebba0ff
- slug
- what-happens-when-you-open-a-website-part-4-ddc82ebba0ff
- url
- https://medium.com/@br10xe.cy/what-happens-when-you-open-a-website-part-4-ddc82ebba0ff
- canonical_url
- https://medium.com/@br10xe.cy/what-happens-when-you-open-a-website-part-4-ddc82ebba0ff
- author_url
- https://medium.com/@br10xe.cy
- status
- ok
- fetched_at
- 2026-07-22 12:16:40