Who takes the packet beyond the local network?
PC-A is 192.168.10.10/24. PC-B at 192.168.10.20 is its local neighbour. A web server at 203.0.113.20 is remote. The switch can carry a frame between local devices, but PC-A needs a router to continue towards the web server.
The default gateway is the next-hop router used by a device's default route when no more specific route matches the destination. On this ordinary IPv4 LAN, it is configured as the address of a router interface on the device's own subnet. It is the device's "way out" of the local network. On a home network it is usually the home router, often at an address like 192.168.1.1.
It is called "default" because the device uses it whenever it has no more specific route. Most PCs know only two things: their own subnet, and the gateway for everything else.
The gateway is the next receiver of the frame; the remote server remains the destination of the IP packet. Learning the gateway's address does not replace the server's address.
Why a PC can't reach other subnets on its own
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Read this figure from PC-A towards the server. The server's 203.0.113.20 address is outside PC-A's /24, so PC-A selects the default route through 192.168.10.1. If the gateway is not already in its ARP cache, PC-A first asks for that gateway's MAC address. It does not ask for the remote server's MAC address.
The resulting Ethernet frame is addressed to R1's Gi0/0 interface. Inside it, the IP packet is still addressed to the server. R1 removes the incoming Ethernet header, looks up the server's destination in its routing table, and sends a new frame from Gi0/1. This small lab has the server directly attached to that second interface, so R1 can resolve the server's MAC there. A larger network may use another router as the next hop instead.
For the reply to work, the server also needs a route back to PC-A; its gateway in this lab is 203.0.113.1. These are documentation addresses in an isolated teaching network, not a real public service. There is no NAT in this figure: routing between subnets and translating addresses are separate operations.
On its own, a PC connected to a switch can only deliver frames to devices on its own local network. In a simple LAN like this one, that local network is one subnet (a range of IP addresses) and one broadcast domain (the devices that receive its broadcasts). The two usually match, but they are different ideas: a subnet is about addressing, a broadcast domain is about which devices a broadcast reaches. Two facts make a gateway necessary:
- Switches don't move traffic between subnets. A Layer 2 switch forwards frames by MAC address inside one network. It does not use IP addresses to decide where to send a frame. (A Layer 3 switch can also route, which is why it can be a gateway, as the table below shows.)
- ARP doesn't cross a router. To send a frame, a PC must learn the receiver's MAC address with an ARP broadcast, and routers don't forward ARP broadcasts. So a PC normally can't learn the MAC address of a server in another network. (The exception is proxy ARP, where a router answers on the server's behalf; the ARP lesson covers it.)
So the PC needs a device on its own subnet that is also connected to other networks and knows how to forward packets between them. That device is a router, and the address of its interface on your subnet is your default gateway. With no default route or other suitable route, a PC can reach its local neighbours but has no route to a remote destination.
One router interface in each subnet
In Figure 1, R1's G0/0 interface is 192.168.10.1/24. G0/0 means a Gigabit Ethernet interface named 0/0 on this example router. PC-A and PC-B use it as their gateway. The server address is a documentation example, not a live target to test; the cloud represents provider routers omitted from the drawing.
Device key: PC-A (laptop) · PC-B (computer)
Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
- PC-A: IP 192.168.10.10/24
- PC-B: IP 192.168.10.20/24
- Router R1: G0/0 = 192.168.10.1
- Web server: IP 203.0.113.20
- 1. Local traffic skips the gateway. Traffic from PC-A to PC-B stays inside 192.168.10.0/24. The switch delivers it to PC-B; the router is not involved.
- 2. Remote traffic goes to the gateway. PC-A sends the packet for the web server to 192.168.10.1, the router's interface on its own subnet.
- 3. The router takes it from there. R1 looks up 203.0.113.20 in its routing table and forwards the packet towards the internet.
- 4. In this topology, replies come back the same way. The reply reaches R1, which delivers it directly to PC-A on the 192.168.10.0/24 subnet. Here R1 is the only way in, so the return path matches; in networks with several routers or links, replies can take a different path (asymmetric routing).
Several kinds of device can act as the gateway:
| Where | Typical gateway device | Typical address |
|---|---|---|
| Home | Home router (router + switch + Wi-Fi + NAT in one box) | 192.168.1.1 or 192.168.0.1 |
| Small office | A router or a firewall | Often .1 or .254 of the subnet |
| Larger office | A Layer 3 switch with one interface per VLAN | One gateway address in every VLAN |
| Cloud network | A virtual router provided by the cloud | Usually the first usable address (.1) of the subnet |
Gateway IP, gateway MAC and the default route
Gateway IP address
Typed in or learned from DHCP, for example 192.168.10.1. It must be inside the host's own subnet, or the host can't reach it.
Gateway MAC address
Learned with ARP the first time it is needed, then kept in the ARP cache. This is the address that goes into the frame.
Default route
Inside the host, the gateway setting becomes a route for 0.0.0.0/0: “send anything I have no better route for via 192.168.10.1”.
The router interface
The gateway is not a whole router; it is one router interface that sits in your subnet. Each subnet has its own gateway address.
A PC gets its gateway either from DHCP (the "router" option, which is how almost all laptops and phones get it) or from a static setting entered by an administrator.
How a PC decides: local or remote?
Before it sends a packet, the PC makes the same decision every time. It uses its own IP address and its subnet mask. In this example, PC-A has:
| IP address | 192.168.10.10 |
| Subnet mask | 255.255.255.0 (/24) |
| Default gateway | 192.168.10.1 |
Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.
Four destinations seen from PC-A
| Destination | What it is | Compare (/24) | PC-A's decision |
|---|---|---|---|
192.168.10.20 | PC-B, same room | 192.168.10 = 192.168.10 | Local: send directly to PC-B |
192.168.10.1 | The gateway itself | 192.168.10 = 192.168.10 | Local: send directly to the router |
192.168.20.5 | File server, other floor | 192.168.10 ≠ 192.168.20 | Remote: send to the gateway |
203.0.113.20 | Web server on the internet | 192.168.10 ≠ 203.0.113 | Remote: send to the gateway |
How the PC really does it: the routing table. The comparison above is the simple version. Technically, the PC looks the destination up in its own routing table, which holds two routes:
| Route | Means | Matches 192.168.10.20? | Matches 203.0.113.20? |
|---|---|---|---|
| 192.168.10.0/24 on-link | Deliver directly | Yes (24 bits match) | No |
| 0.0.0.0/0 via 192.168.10.1 | Default route: send to the gateway | Yes (0 bits to match) | Yes |
When several routes match, the one with the longest prefix (the most matching bits) wins. For 192.168.10.20 the /24 beats the /0, so delivery is direct. For 203.0.113.20 only the default route matches, so the packet goes to the gateway. Routers use exactly the same rule, with many more routes.
Why remote traffic goes to the gateway
The PC can't send a frame straight to 203.0.113.20, because it can't learn that server's MAC address: its ARP broadcast would never leave the local subnet. Even if it could, a MAC address is only useful on one local link. So the PC does the only thing it can: it hands the packet to a device on its own link that can move it further. The router accepts the frame (because it is addressed to the router's MAC address), removes the Ethernet header, reads the destination IP address and forwards the packet towards its destination in a new frame.
The local frame and the remote frame side by side
This is the most important idea in this lesson. Compare the frame that PC-A sends to a local neighbour with the frame it sends to a remote server. This lesson uses these addresses:
| Device | IP address | MAC address |
|---|---|---|
| PC-A | 192.168.10.10 | 02:00:00:00:00:aa |
| PC-B | 192.168.10.20 | 02:00:00:00:00:bb |
| Gateway (R1 G0/0) | 192.168.10.1 | 02:00:00:00:00:01 |
| Web server | 203.0.113.20 | Unknown to PC-A, and not needed |
Local: PC-A → PC-B
Destination is on 192.168.10.0/24
Remote: PC-A → web server
Destination is NOT on 192.168.10.0/24
In the remote frame, the two layers point at different devices. The destination MAC says "this frame is for the gateway"; the destination IP says "this packet is for the web server". The gateway's IP address 192.168.10.1 appears nowhere in the frame or the packet. The PC only uses it to look up the gateway's MAC address with ARP.
Try it: follow one packet
Pick a destination and watch every frame PC-A sends. The panel under the diagram shows the two sets of addresses for each step: the frame (MAC addresses, valid for one link) and the packet (IP addresses, end to end).
Device key: PC-A (laptop) · PC-B (computer)
Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
MAC addresses identify link-layer interfaces or destination groups. They are not IP addresses or website URLs.
- PC-A: IP 192.168.10.10/24
- PC-B: IP 192.168.10.20/24
- Router R1: G0/0 = 192.168.10.1
- Web server: IP 203.0.113.20
Tip: click or tap a device to see its details.
- 1. Decide: 192.168.10.20 is in PC-A's own network 192.168.10.0/24, so PC-A delivers it directly. The gateway is not used.
- 2. ARP request: PC-A broadcasts: who has 192.168.10.20? Every device on the subnet receives it; only PC-B answers.
- 3. ARP reply: PC-B answers with its MAC address. PC-A stores it in its ARP cache.
- 4. Frame to PC-B: The MAC and IP destinations are both PC-B. The switch forwards the frame out of PC-B's port only; R1 does not receive it.
- 5. Reply: PC-B answers straight back. It learned PC-A's MAC address from the ARP request, so it needs no ARP of its own.
Later lessons follow this exact journey again, hop by hop.
Learn more: ARP for Local and Remote DestinationsDifferent-Subnet Communication
Opening a website from a home laptop
- Your laptop (
192.168.1.10/24) got its settings from the home router by DHCP, including the gateway192.168.1.1. - You open a website. DNS returns its address,
203.0.113.20. - The laptop compares the network parts: 192.168.1 ≠ 203.0.113, so the site is remote.
- It already has the router's MAC address in its ARP cache, so it sends the frame straight to the router.
- The home router translates the source address with NAT and sends the packet to the internet provider.
- The reply comes back to the router, which reverses the NAT translation and delivers it to the laptop on the local subnet. (Here it must come back through the same router, because that router holds the NAT translation. In networks with several exits, return traffic can take a different path, which is called asymmetric routing.)
Even the DNS query in step 2 goes through the gateway if the DNS server is outside the local subnet. Almost everything a laptop does online passes through the default gateway.
What happens when the gateway is wrong or missing
A gateway problem has a very typical signature: local devices work, everything else fails. Here are the common cases for PC-A:
| Problem | Example setting | What happens |
|---|---|---|
| No gateway | (blank) | PC-A has no default route, so remote destinations fail immediately. Windows ping shows "transmit failed. General failure"; Linux shows "Network is unreachable". |
| Gateway address nobody uses | 192.168.10.99 | PC-A sends an ARP request for .99 and gets no reply. Remote pings report "Destination host unreachable" from PC-A's own address. |
| Gateway is another PC | 192.168.10.20 (PC-B) | ARP works, so frames go to PC-B. PC-B is not a router, so it normally drops them. Remote traffic simply times out. |
| Gateway in a different subnet | 192.168.20.1 | PC-A can't reach it directly. Most systems warn you or refuse the setting; if it is accepted, remote traffic fails. |
| Correct gateway, but the router is down | 192.168.10.1 | The same as an unused address: no ARP reply and no ping reply. Every PC on the subnet loses access to other networks at once. |
In practice, wrong gateways turn up most on devices with static addresses (printers, cameras, servers) after a subnet is renumbered or a device is moved. DHCP clients pick up the new gateway by themselves; static ones keep the old setting until someone changes it.
Device key: PC-A (laptop) · PC-B (computer)
Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
- PC-A: gateway set to .99 ✗
- PC-B: IP 192.168.10.20
- Router R1: IP 192.168.10.1
- Web server: IP 203.0.113.20
- 1. Local still works. PC-B is on the same subnet, so the gateway setting is not used.
- 2. PC-A asks for the wrong gateway. To reach the web server, PC-A sends an ARP request for 192.168.10.99. Every device receives it, but nobody has that address.
- 3. No MAC, no frame. With no ARP reply, PC-A can't build the frame. Ping reports “Destination host unreachable”, and the router never even receives the packet.
Reading the gateway from ipconfig and ip route
Windows
C:\> ipconfig Ethernet adapter Ethernet: IPv4 Address. . . . . . . . . . . : 192.168.10.10 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.10.1
255.255.255.0 mask), and it is not your own address.C:\> route print -4 IPv4 Route Table =========================================================================== Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.10.1 192.168.10.10 25 127.0.0.0 255.0.0.0 On-link 127.0.0.1 331 192.168.10.0 255.255.255.0 On-link 192.168.10.10 281 192.168.10.10 255.255.255.255 On-link 192.168.10.10 281 192.168.10.255 255.255.255.255 On-link 192.168.10.10 281 ===========================================================================
0.0.0.0 and netmask 0.0.0.0 is the default route, created from the gateway setting; its Gateway column shows 192.168.10.1. On-link means "deliver directly", so 192.168.10.0 / 255.255.255.0 On-link is the local subnet.C:\> ping 192.168.10.1 Pinging 192.168.10.1 with 32 bytes of data: Reply from 192.168.10.1: bytes=32 time<1ms TTL=255 Reply from 192.168.10.1: bytes=32 time<1ms TTL=255 Reply from 192.168.10.1: bytes=32 time<1ms TTL=255 Reply from 192.168.10.1: bytes=32 time<1ms TTL=255 Ping statistics for 192.168.10.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)
C:\> ping 203.0.113.20 Pinging 203.0.113.20 with 32 bytes of data: Reply from 192.168.10.10: Destination host unreachable. Reply from 192.168.10.10: Destination host unreachable. Reply from 192.168.10.10: Destination host unreachable. Reply from 192.168.10.10: Destination host unreachable.
192.168.10.10. The PC is telling you it couldn't find the next hop's MAC address with ARP. That points to a wrong gateway setting or a gateway that is down.Linux route checks, with macOS alternatives
$ ip route default via 192.168.10.1 dev eth0 proto dhcp metric 100 192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.10 metric 100
default via 192.168.10.1 line is the default route, so 192.168.10.1 is the gateway. proto dhcp shows it was learned from DHCP. The second line is the local subnet. On macOS, use netstat -rn or route -n get default.$ ip route get 203.0.113.20 203.0.113.20 via 192.168.10.1 dev eth0 src 192.168.10.10 uid 1000 cache
via 192.168.10.1 means "remote, through the gateway". For a local address such as 192.168.10.20, the answer has no via: 192.168.10.20 dev eth0 src 192.168.10.10.Working outwards from the PC
Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.
The troubleshooting unit and the command guides give you more practice.
Learn more: IP and Gateway ProblemsEssential Windows Network CommandsEssential Linux Network Commands
Gateway mistakes that look like an internet outage
- Thinking the destination IP becomes the gateway's IP. It doesn't. Only the destination MAC address points at the gateway.
- Putting the gateway in a different subnet from the PC. The PC can't reach it with ARP. This often happens after copying settings from another office.
- Setting a server's gateway to its own address. A server is not a router, so remote traffic has nowhere to go.
- Blaming the gateway when local traffic also fails. If PC-B is unreachable too, check the cable, the switch or the IP address first.
- Setting default gateways on two adapters. The PC chooses one by metric, and traffic can leave through the wrong interface.
- Assuming the gateway is always .1. It is only a convention, so check the real setting.
- The default gateway is the next-hop router used when no more specific route matches. It also needs a usable onward route.
- The PC uses its subnet mask to compare network parts: same → deliver directly; different → send to the gateway.
- For remote traffic: destination MAC = gateway, destination IP = the remote host.
- For a remote destination, the PC uses ARP to find the gateway's MAC address, not the remote host's.
- Local works and remote fails: investigate the gateway and routing, then DNS and the remote service. This symptom alone does not identify the failed component.
The shared folder works, but no website loads
A user at 192.168.10.37 reports: "I can open the shared folder on PC-B, but no website loads." You ask them to run ipconfig:
C:\> ipconfig Ethernet adapter Ethernet: IPv4 Address. . . . . . . . . . . : 192.168.10.37 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1
Short lab: follow the selected next hop
Use your own PC and addresses. Reading a routing table does not change it. Do not set your adapter to the example IPs on a live network.
- On Windows, run
ipconfigandroute print -4. Find the active adapter and compare its gateway with the route whose destination and mask are both0.0.0.0. - Predict the frame destination for a local host and a remote host. For remote traffic using the default route, the Ethernet destination is the gateway's MAC address.
- Use
ping <your-gateway-address>and inspectarp -a. An ARP entry confirms a local address mapping; a ping reply confirms an ICMP (Internet Control Message Protocol) response. Neither alone proves that a remote website works. - On Linux, run
ip route get <destination-address>. Readviaas the next hop,devas the outgoing interface andsrcas the chosen source address. Replace the bracketed text with an address relevant to your network.
A single gateway keeps host configuration simple, but it can be a point of failure. Larger networks can provide a shared virtual gateway backed by two routers. The PC still uses one address while the routers manage failover. That is a later topic, not something this lab assumes.
Test yourself on gateways and frames
In the ipconfig output above, what is wrong?
PC-A (192.168.10.10/24, gateway 192.168.10.1) sends a packet to 203.0.113.20. What is the destination MAC address of the frame it sends?
PC-A sends a packet to 203.0.113.20 through the gateway. What is the destination IP address in the packet?
A ping to 203.0.113.20 shows "Reply from 192.168.10.10: Destination host unreachable." (192.168.10.10 is the PC itself). What does this tell you?
PC-A's gateway is set to 192.168.10.20, which is PC-B (an ordinary PC). What happens to traffic for the internet?
To see how a device turns the gateway's IP address into a MAC address, continue with ARP.
Learn more: ARP Fundamentals
Technical references
The host forwarding model follows RFC 1122, section 3.3.1. Windows configuration output follows Microsoft ipconfig documentation. Outputs are teaching examples rather than a report of your network.