Setting and changing routes is a common enough requirement on a network.
Cisco Commands useful for managing routes include:
- show ip route
- no ip route IP NETMASK GATEWAY
- ip route IP NETMASK GATEWAY
All commands are functional only inside the 'terminal' configuration prompt "...(config)#"
show ip route
Let's you see the routing configuration. Related commands include:
#show ip route
Default gateway is not set Host Gateway Last Use Total Uses Interface ICMP redirect cache is empty
#show running-config | i routing
no ip routing
#config t (config)#router ospf 5
IP routing not enabled
no ip route IP NETMASK GATEWAY
Removes the routing for IP NETMASK GATEWAY.
When the no command is used before any other configuration-mode command - it's the way that you tell a Cisco Switch to unset a setting.
For example, no ip route x.y.z.q netmask destination. no router bgp ASN would be fairly disastrous, though - it would take out the "router bgp" clause and all of the neighbor and other statements underneath it.
To delete a neighbor and re-enter it, use router bgp ASN and then no neighbor x.y.z.q.
(config)# no ip route 192.168.25.0 255.255.255.0 192.168.18.100
ip route IP NETMASK GATEWAY
ip route x.y.z.q NETMASK GATEWAY [metric]
The "ip route" command installs a route to the IP space starting at x.y.z.q and spanning the length specified by netmask, pointed towards gateway as a next-hop. Gatewaycan be an interface name or IP address.
The metric tag is optional (which is why it's shown in brackets). The netmask used to be optional, but no longer is - and even on routers where it is optional it never hurts to be specific!
(config)# ip route 192.168.25.0 255.255.255.0 192.168.25.1
We can now review a summary command-script that deletes and existing route, adds a new route, shows the route to us, then saves the route to the firmware.
> enable # config terminal (config)# no ip route 192.168.25.0 255.255.255.0 192.168.18.100 (config)# ip route 192.168.25.0 255.255.255.0 192.168.25.1 (config)# show ip route (config)# end # copy running-config startup-config # reload