The Concept of the Default Gateway
In Practical classes 5–6 you filled in the “Default Gateway” line and received it through DHCP. Today we look at the inner mechanics of that line: how a computer decides whether to send a packet straight to its neighbor or hand it to the gateway, why the MAC address changes along the way but the IP does not, and how Windows “speaks” when the gateway is wrong. You will fix the router yourself in a Cisco console.
Lesson goals and plan
By the end of the lesson you will…
- explain the concept of the default gateway and its role in a local network
- determine whether an address is local or remote by a bitwise AND of the IP and the mask
- show how the Ethernet frame (MAC) and the IP header change when a packet passes through a gateway
- find the gateway in the output of route print, arp -a, tracert and Cisco show ip route
- diagnose by their signs the cases where there is no gateway, it is on another network, or the router interface is down
- model with Python’s ipaddress the local/remote decision and route selection by the longest prefix
Plan (according to the syllabus)
- The Concept of the Default Gateway
Today there is one main question: “Is this address on the same network as me?” Yes — the packet goes straight to the neighbor. No — to the gateway. Everything else is a consequence of this question. In the simulator first see the mistake, then fix it in the console.
In the department a new computer was set up by hand. A document goes to the printer in the room, and the shared folder on the neighboring computer opens — so both the cable and the IP are in place. But no site opens in the browser. In ipconfig everything is there, except for one empty line: Default Gateway. The local network is a corridor inside the room, and the gateway is the only door out of the building. If the door is not indicated, you cannot leave the building.
Key terms
Theory reminder
Before sending each packet, a computer makes one decision. It uses the mask operation from Practical classes 3–4:
Local (the networks are equal)
192.168.1.10 AND 255.255.255.0 = 192.168.1.0 192.168.1.11 AND 255.255.255.0 = 192.168.1.0
→ ARP: “Who has 192.168.1.11?” → the frame goes straight to PC-B’s MAC address.
Remote (the networks differ)
192.168.1.10 AND 255.255.255.0 = 192.168.1.0 8.8.8.8 AND 255.255.255.0 = 8.8.8.0
→ ARP: “Who has 192.168.1.1 (the gateway)?” → the frame goes to the router’s MAC address, while the IP address remains 8.8.8.8.
The default gateway is the next-hop address of the 0.0.0.0/0 entry in a host’s routing table: the local router interface to which packets for all addresses outside its own network are handed. The gateway must be on the same network as the host — otherwise the host cannot reach it with ARP.
The Concept of the Default Gateway
Two labs and two sample tasks. The network is as follows: room 1 (192.168.1.0/24), room 2 (192.168.2.0/24) and between them the router R1, and R1 reaches the Internet through a provider.
Sample task 1. Three ways to find the gateway in Windows
- ipconfig
The “Default Gateway” line. The fastest, but it is only the setting — it does not tell you whether it works or not.
- route print — the routing table
The row
Network Destination 0.0.0.0, Netmask 0.0.0.0is the default route. Its Gateway column is the gateway. Here you see the computer’s real decision table. - arp -a — is the gateway alive?
After pinging the gateway once, its IP–MAC pair appears in
arp -a. If it does not appear, ARP got no reply: the router is off or the address is wrong. - tracert — the first hop
tracert -d 8.8.8.8: the address on line 1 is the gateway to which the packet was really handed.
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.10 25
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
192.168.1.0 255.255.255.0 On-link 192.168.1.10 281
192.168.1.10 255.255.255.255 On-link 192.168.1.10 281
192.168.1.255 255.255.255.255 On-link 192.168.1.10 281
===========================================================================On-link — “this network is directly connected to me, no gateway is needed.” Only the 0.0.0.0 row has a real gateway written.
Interface: 192.168.1.10 --- 0xc Internet Address Physical Address Type 192.168.1.1 00-1a-2b-3c-00-01 dynamic 192.168.1.11 00-50-56-a1-00-11 dynamic 192.168.1.255 ff-ff-ff-ff-ff-ff static
Note: 8.8.8.8 is not in the table. The computer does not know the MAC of any server on the Internet and does not have to — it knows only the gateway’s MAC.
Tracing route to 8.8.8.8 over a maximum of 30 hops 1 <1 ms <1 ms <1 ms 192.168.1.1 2 3 ms 2 ms 3 ms 203.0.113.1 3 * * * Request timed out. 4 28 ms 27 ms 29 ms 8.8.8.8 Trace complete.
Hop 1 is the gateway (R1). The * on line 3 means that router is configured not to reply with ICMP; the packets pass anyway (line 4 exists). So a single * is not yet a fault.
Lab 1: a packet-path simulator
Choose PC-A’s setting (or change it by hand), pick an address and press Send. On the left is the packet’s movement, on the right the decisions made by the computer and the router: the AND calculation, ARP, the frame headers. In the initial state the R1 G0/1 interface is down — there is no path to room 2. You will fix it in Lab 2 below.
:ik-tarmoq: Sending a packet from PC-A
Sample task 2. Configuring a router interface as the gateway
Condition: The computers in room 2 use 192.168.2.1 as the gateway, but on R1 this address exists nowhere and the G0/1 interface is down. Configure R1.
- Look at the state
show ip interface brief— G0/1:unassigned,administratively down.show ip route— there is no 192.168.2.0/24. - Enter the interface
configure terminal→interface g0/1→ the prompt is(config-if)#. - Write the gateway address
ip address 192.168.2.1 255.255.255.0— it must be exactly the same as the “Default Gateway” on the computers. - Turn it on
no shutdown. On Cisco routers interfaces are off by default — this is the most often forgotten step. - Check
end→show ip routewill showC 192.168.2.0/24→ping 192.168.2.20. Then in Lab 1 send PC-A → PC-C again.
Lab 2: the R1 console
Abbreviations work: en, conf t, int g0/1, sh ip int br, sh ip ro, no shut. In configuration mode do show …. ? is help.
:ik-terminal: R1 (Cisco IOS simulator)
- look at
show ip routeand find the “Gateway of last resort” 192.168.2.1 255.255.255.0is written on G0/1- G0/1 is turned on (
no shutdown) ping 192.168.2.20from R1 succeeds- in Lab 1, PC-A → PC-C (the correct setting) succeeds
Test cases: predict first, then check in the simulator
Independent tasks
6 programs: we repeat in Python the decisions made by the computer and the router. input() without a prompt text.
Common mistakes
| Error | Sign | Correct answer |
|---|---|---|
| The gateway is not written | Local works; an outside address — General failure | Default gateway = the router interface |
| The gateway is from another subnet | Windows warns and saves; an outside address — General failure | Gateway IP AND mask = the computer’s network |
| A neighboring computer or printer as the gateway | Request timed out | Only a router (or an L3 device) can be a gateway |
The router interface is in the shutdown state | The whole room has no Internet, no ping to the gateway | no shutdown; show ip interface brief |
| The gateway on the computer and the router interface address do not match | The request goes out, the reply does not come back | Make both sides the same (the DHCP default-router too) |
| Thinking “the IP address changes along the way” | A wrong analysis | At each hop the MAC changes, the IP does not (except with NAT) |
1) dst remained a string — ip_address() is needed. 2) Membership is checked against the network: i.network, not i.ip. 3) The answer must show the gateway (gw), not the computer’s own IP (which is not even a string — it cannot be concatenated).
Boss level
Boss level: a ping result predictor
You are a help-desk engineer. The program, from a computer’s setting and the list of devices on the local network, tells the ping result and its cause. The input: IP/prefix; the gateway (- means none); the devices on the network on one line separated by spaces (routers marked with :R, for example 192.168.1.1:R); an address. The output is two lines: Qaror: lokal or Qaror: shlyuz orqali, then Natija: … +60 XP
- Local: if the address is among the devices —
Natija: Reply from MANZIL, otherwiseNatija: Destination host unreachable (ARP javobsiz). - Through the gateway: no gateway →
Natija: General failure (shlyuz yo‘q); the gateway is on another network →Natija: General failure (shlyuz boshqa tarmoqda); the gateway is not among the devices →Natija: Destination host unreachable (shlyuz javob bermadi); the gateway exists but is not a router →Natija: Request timed out (shlyuz router emas); otherwiseNatija: paket shlyuzga topshirildi.
Reinforcement
Review questions
What is a default gateway and why is it needed?
The address of the router interface on the local network; packets for all addresses outside its own network are handed to it. Without it a computer works only in its own subnet.
How does a computer tell whether an address is local or remote?
It does a bitwise AND of its own IP and the address with the mask. If the results are equal — local; if different — remote.
Why must the gateway be on the same network as the computer?
The computer sends the frame to the gateway’s MAC address, and the MAC is found with ARP; an ARP broadcast works only on the local segment.
When a packet passes through a router, what changes and what does not?
It changes: the Ethernet frame (src/dst MAC) and the TTL. It does not change: the src/dst IP (without NAT).
What is the difference between the messages General failure, Destination host unreachable and Request timed out?
General failure — the packet cannot be sent at all (no gateway / on another network). Unreachable — ARP got no reply or a router said “no route”. Timed out — the packet went out, no reply came.
With which commands can you find and check the gateway in Windows?
ipconfig, route print (the 0.0.0.0 row), arp -a (the gateway’s MAC), ping to the gateway, tracert (hop 1).
What are the steps to bring up an interface as a gateway on a Cisco router?
configure terminal → interface g0/1 → ip address 192.168.2.1 255.255.255.0 → no shutdown; to check: show ip interface brief, show ip route.
If the mask is wrong (/16 instead of /24, or vice versa), what signs appear?
Some addresses are wrongly treated as “local” (unreachable) or, on the contrary, needlessly sent to the gateway; the result is a mixed picture: “some places open, some do not”.
Independent work
The independent-study topic in the course syllabus: “The fundamentals of routing and static and dynamic routing methods” (6 hours). In Cisco Packet Tracer build the network of your variant: a router and two (or three) LANs. Configure the router interfaces, write the gateway on the computers, then provide: (1) the results of ipconfig, route print, tracert; (2) in Simulation mode, a table of the frame headers of one packet on each segment (src/dst MAC and IP); (3) deliberately create one gateway fault and show its sign.
| Criterion | Points |
|---|---|
| The network works: ping and tracert between the LANs succeed | 2 |
| The table of frame headers (MAC and IP on each segment) is correct | 1 |
| A fault was created; its sign and fix are shown | 1 |
| The route print / show ip route outputs are explained | 1 |
Summary
Your lesson results
Your results are saved in this browser. Read all the sections and complete the exercises and assignments.