Question
Why does a switch need a default gateway and how do you configure it?
Answer
A Layer 2 switch needs a default gateway only so its own management traffic (SSH/Telnet/HTTP) can reach an admin on another network; set it with the ip default-gateway ip-address global command.
Default Gateway on a Switch:
A Layer 2 switch needs a default gateway to be remotely managed from another network.
Why switches need a default gateway:
- Switch management traffic (Telnet, SSH, HTTP) originates from the switch
- Without a gateway, management is only possible from the local network
- The switch SVI (VLAN interface) needs an IP for management
Configuration command:
Switch(config)# ip default-gateway ip-address
Example:
S1(config)# interface vlan 1
S1(config-if)# ip address 192.168.10.50 255.255.255.0
S1(config-if)# no shutdown
S1(config-if)# exit
S1(config)# ip default-gateway 192.168.10.1
Important distinction:
- Routers do NOT use
ip default-gateway- they use default routes (ip route 0.0.0.0 0.0.0.0 next-hop) - Switches use
ip default-gatewayfor management traffic only
Go deeper:
Default gateway (Wikipedia) — the gateway concept a switch needs so its own management traffic can leave the local network.
Static routing — default route (Wikipedia) — the
0.0.0.0/0default route routers use, contrasted with a switch'sip default-gateway.
Note saved — thanks!
Question
What are the three types of routes in a router's routing table?
Answer
Directly connected (added automatically for active, addressed interfaces), remote (learned statically or dynamically), and the default route (used when nothing else matches).
* Directly connected routes are automatic; remote routes are learned statically or dynamically; the default route catches everything else. *
Three types of routes in a routing table:
| Route Type | Description | How Added |
|---|---|---|
| Directly Connected | Networks attached to the router's interfaces | Automatically added when interface is active with addressing |
| Remote | Networks NOT directly attached to the router | Learned manually (static) or dynamically (routing protocol) |
| Default Route | Used when NO other route matches | Forwards all unmatched traffic to a specific direction |
Remote routes can be learned:
- Statically - Administrator manually configures the route
- Dynamically - Routing protocols (OSPF, EIGRP, etc.) share information between routers
Default route:
- Often called the "gateway of last resort"
- Represented as 0.0.0.0/0 in IPv4
- Used when the destination doesn't match any specific route
Go deeper:
Wikipedia — Routing table — directly connected, static, dynamic, and default route entries.
Note saved — thanks!