Configure IPv4 Static Routes Settings on a Switch through the CLI
PDF(19.6 KB) View with Adobe Reader on a variety of devices
ePub(101.8 KB) View in various apps on iPhone, iPad, Android, Sony Reader, or Windows Phone
Mobi (Kindle)(77.7 KB) View on Kindle device or Kindle app on multiple devices
Updated:July 20, 2020
This article provides instructions on how to configure IPv4 static routes on the switch through the Command Line Interface (CLI).
Static routing refers to the configuration of the path selection of routers. This type of mechanism takes place in the absence of communication between routers regarding the current topology of the network and thus, manually configuring routes to the routes table on the switch is recommended. Static routes help reduce the overhead on the switch CPU. This feature also allows you to deny access to certain networks.
When routing traffic, the next hop is decided on according to the longest prefix match (LPM) algorithm. A destination IPv4 address may match multiple routes in the IPv4 Static Route Table. The device uses the matched route with the highest subnet mask, that is, the longest prefix match. If more than one default gateway is defined with the same metric value, the lowest IPv4 address from among all the configured default gateways is used.
Note: For instructions on how to configure IPv4 static routes settings on the switch through the web-based utility, click here.
You cannot configure a static route through a directly‑connected IP subnet where the device gets its IP address from a DHCP server. To configure a static IPv4 interface on the switch, click here for instructions.
Step 1. Log in to the switch console. The default username and password is cisco/cisco. If you have configured a new username or password, enter the credentials instead.
To learn how to access an SMB switch CLI through SSH or Telnet, click here.
Note: The commands may vary depending on the exact model of your switch.
Step 2. To display the current routes on the switch, enter the following:
CBS350#show ip route
Note: In this example, a directly connected route to 192.168.100.0 network is displayed.
Step 3. From the Privileged EXEC mode of the switch, enter the Global Configuration mode by entering the following:
Step 4. In the Global Configuration mode, enter the ip route command to establish static routes:
prefix-length - Prefix mask for the destination. It specifies the number of bits that comprise the IP address prefix. The prefix length must be preceded by a forward slash (/). The range can be from 0 to 32.
ip-address - IP address of the next hop that can be used to reach that network.
metric value - Metric of the route. The default metric is 6 for the Next Hop on an In-Band interface and 2 for the Next Hop on Out-of-Band (OOB). The range can be from one to 255.