Hands-On Lab: Configuring a Default Gateway for Routers and Switches

This hands-on lab configures a default gateway on a Layer 2 switch's management interface so it can be reached and managed from a remote subnet, and distinguishes this from a router's own default route used to reach networks beyond its directly connected interfaces.

Switch Default GatewayManagement VLANDefault Route Distinction

~3 min read · Updated Sep 22, 2026

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.1

Task 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)# exit

Switch1(config)# ip default-gateway 192.168.1.1

ManagementPC (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 subnet

R1(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 not

Key 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.

Written & researched by Dr. Shahin Siami

Related Articles

Hands-On Lab: Configuring IPv6 Static Routes

This hands-on lab configures static routes for IPv6 destinations between two routers, mirroring the IPv4 static routing syntax covered earlier in this series while highlighting the IPv6-specific command keyword and address format.

Continue

Hands-On Lab: Configuring Default Static Routes

This hands-on lab configures a default static route on an edge router to reach the internet through an ISP connection, demonstrating how a single route can represent every otherwise-unknown destination rather than requiring individual routes for each one.

Continue

Hands-On Lab: Configuring and Naming Static Routes

This hands-on lab configures static routes with descriptive names attached using the name keyword, improving documentation and making the routing table significantly easier to interpret for anyone reviewing the configuration later.

Continue

Hands-On Lab: Configuring Static Routing via IP Addresses

This hands-on lab configures static routes using a next-hop IP address rather than an outgoing interface, the generally preferred syntax, and compares the resulting routing table entry against the interface-based approach from the previous lab.

Continue

Hands-On Lab: Configuring Static Routing via Interfaces

This hands-on lab configures static routes using an outgoing interface rather than a next-hop IP address, demonstrating this approach's suitability for point-to-point links and its important limitation on multi-access networks.

Continue

Hands-On Lab: Installing a Wireless LAN Controller

This hands-on lab performs the initial setup of a Wireless LAN Controller, joins a lightweight access point to it, and creates a centrally managed WLAN, demonstrating the controller-based architecture that scales far beyond standalone access points.

Continue