RoutingGlobal Config

ip default-gateway [ip]

Sets the default gateway for a Cisco switch that is not configured with IP routing, allowing it to forward management traffic to remote networks.

Syntax·Global Config
ip default-gateway [ip]

When to Use This Command

  • Configuring a default gateway on a Layer 2 switch so it can be managed from a different subnet
  • Providing a fallback route for a router that does not have dynamic routing enabled and needs a static default route
  • Setting a default gateway on a device that only has a single exit path to the rest of the network
  • Ensuring management traffic (e.g., SNMP, SSH, syslog) can reach a network management station in a different subnet

Command Examples

Setting a default gateway on a Layer 2 switch

ip default-gateway 192.168.1.1

This command sets the default gateway to 192.168.1.1. No output is displayed upon successful configuration. Use 'show ip route' or 'show running-config' to verify.

Verifying the default gateway configuration

show ip route
Default gateway is 192.168.1.1
Host               Gateway           Last Updated
192.168.1.1        0.0.0.0          00:00:00

The output shows the configured default gateway. 'Host' is the gateway IP, 'Gateway' is the next-hop (0.0.0.0 means directly connected), and 'Last Updated' indicates when the entry was last refreshed.

Understanding the Output

The 'show ip route' command on a Layer 2 switch displays the default gateway under 'Default gateway is ...'. The table shows 'Host' (the gateway IP), 'Gateway' (the next-hop IP, usually 0.0.0.0 for a directly connected gateway), and 'Last Updated' (time since the entry was last updated). A missing or incorrect default gateway will show no entry or a wrong IP. Ensure the gateway IP is reachable and that the switch has a management interface in the same subnet as the gateway.

CCNA Exam Tips

1.

CCNA exam tip: Remember that 'ip default-gateway' is used on Layer 2 switches, while 'ip route 0.0.0.0 0.0.0.0 [next-hop]' is used on routers and Layer 3 switches with IP routing enabled.

2.

CCNA exam tip: The command is configured in global configuration mode and does not require 'ip routing' to be enabled.

3.

CCNA exam tip: If a switch has multiple VLANs, the default gateway must be reachable from the management VLAN interface (SVI).

4.

CCNA exam tip: On a router, 'ip default-gateway' is ignored if 'ip routing' is enabled; use 'ip route 0.0.0.0 0.0.0.0' instead.

Common Mistakes

Mistake 1: Using 'ip default-gateway' on a router with IP routing enabled — the command is ignored; use 'ip route 0.0.0.0 0.0.0.0' instead.

Mistake 2: Forgetting to configure a management interface (SVI) in the same subnet as the default gateway — the switch cannot reach the gateway.

Mistake 3: Typing the wrong IP address or subnet mask — the command only takes an IP address, no mask.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with hundreds of CCNA practice questions covering all exam domains.

Practice CCNA Questions