Lab Objective
Configure a default gateway on a Layer 2 switch so it can be reached for management purposes from a remote subnet, and separately configure an equivalent default route on a router, clarifying the distinct terminology each device uses for a conceptually similar purpose.
Lab Purpose
A pure Layer 2 switch has no routing table and cannot route packets, yet it still needs a way to send management traffic (like SSH responses or SNMP traps) toward destinations outside its own local subnet — this is precisely what its default gateway setting accomplishes, distinct from a router's full routing capability.
Lab Topology
Switch1 (Layer 2 only)
VLAN 1 management interface: 192.168.1.50/24
Needs to be managed from 192.168.99.0/24
via a router at 192.168.1.1
R1 (Layer 3 router)
Needs a default route toward its ISP
at 203.0.113.1Task 1: Configure the Switch's Management IP
Assign an IP address to Switch1's VLAN 1 interface.
Task 2: Configure the Switch's Default Gateway
Set the switch's default gateway so management traffic destined for remote subnets can be forwarded correctly.
Task 3: Verify Remote Management Access
Confirm a management station on 192.168.99.0/24 can successfully reach the switch.
Task 4: Configure the Router's Default Route
On R1, configure a default route pointing toward the ISP, using the equivalent router concept.
Task 5: Compare the Two Commands
Note the different command syntax each device uses for a conceptually related purpose.
Solution and Verification
Switch1(config)# interface vlan 1
Switch1(config-if)# ip address 192.168.1.50 255.255.255.0
Switch1(config-if)# no shutdown
Switch1(config-if)# exitSwitch1(config)# ip default-gateway 192.168.1.1ManagementPC (192.168.99.10)> ssh 192.168.1.50
-- Successfully connects, since the switch now
-- knows to forward its SSH response traffic
-- through 192.168.1.1 to reach the remote
-- 192.168.99.0/24 subnetR1(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1
-- This is R1's default ROUTE, discussed
-- earlier in this series regarding static
-- routing -- functionally similar in intent
-- to the switch's default GATEWAY, but using
-- entirely different syntax and mechanics,
-- since R1 actually maintains a full routing
-- table while Switch1 does notKey Takeaway
A Layer 2 switch uses ip default-gateway because it has no routing table of its own — this single setting exists purely to let the switch's own management traffic escape its local subnet. A router instead uses ip route 0.0.0.0 0.0.0.0 to add an actual default route entry into its full routing table, which is used for forwarding transit traffic on behalf of other devices, not just its own management sessions.