ip route
Creates or deletes static routes.
Syntax: ip route route-prefix mask gateway [distance] [tag tag] ip route route-prefix mask null0
no ip route route-prefix mask gateway [distance] [tag tag]
route-prefix
Destination IP network address.
mask
The mask associated with the destination network address.
gateway
IP address of the next hop used to reach the destination address. Traffic destined for the network specified by route-prefix is routed through this gateway over any other gateway.
NOTE: The gateway IP address must be on a directly connected network.
distance
Administrative distance or preference. When you use static routes with one of the routing protocols, distance is used to determine whether the static route is preferred over routes learned via the routing protocol updates. A low distance specifies that this route takes precedence over the route with a higher distance.
tag tag
A value applied to the route. Tags are used to identify routes for redistribution and route maps. Valid values for tag are integers between 1 and 4294967295.
Description: Static routes are user-configured routes that move packets to a destination along a specified path.
Use the ip route route-prefix mask gateway syntax to configure a static path to the specified destination via the specified gateway. This command can be entered multiple times to configure multiple gateways for the destination. When more than 4 are entered, only the first 4 that are usable are installed.
Static routes can be overridden by dynamically-learned routes by careful configuration of the distance argument. Each routing protocol has a default distance. To override a static route, configure the distance for the static route as more than the default distance for the routing protocol.
Each routing protocol has a default distance:
Use the distance argument to configure the distance of a route so that it can be compared to routes learned from dynamic routing protocol updates.
Use the tag tag keyword and argument to append the specified tag to the route.
Use the ip route route-prefix mask null0 syntax to create a black hole route with a next hop of 127.0.0.1. Black holes provide a convenient method for routing protocols to discard undesirable route updates without the processing overhead of access lists.
Use the no ip route route-prefix mask gateway [distance] syntax to delete a static route. The no form of the command accepts a gateway or distance specifier to help identify the route to be deleted.
Factory Default: No static routes configured.
Command Mode: Configuration.
Example 1: In the following example,
- The first four octets are the IP address of the destination network.
- The second four octets are the network mask associated with the destination address.
- The last four octets are the address of the gateway through which packets destined for network 192.136.136.0 are forwarded:
router(config)#ip route 192.136.136.0 255.255.255.0 10.1.9.12
Example 2: In the following example, the distance argument is used to configure the distance for the route as 20, making it a a more preferred route than most supplied by routing protocol updates:
router(config)#ip route 17.1.0.0 255.255.0.0 10.1.9.12 20
Example 3: In the following example, the tag keyword appends a tag of 1000 to the route:
router(config)#ip route 193.1.1.0 255.255.255.0 10.1.9.1 tag 1000
Example 4: In the following example, the route to subnet 192.136.136.0 is deleted:
router(config)#no ip route 192.136.136.0 255.255.255.0
Example 5: In the following example, the null0 keyword creates a blackhole route with the next hop of 127.0.0.1 for any messages for whom the destination network is 194.12.12.0:
router(config)#ip route 194.12.12.0 255.255.255.0 null 0
Example 6: In the following example, the ip route commands are used to configure an ECMP set:
- The router isis command enables IS-IS routing.
- The maximum-paths command sets the maximum number of equal-cost multi-paths to 4.
- The ip route commands define an ECMP set of 4 static routes with the same destination address and netmask, but 4 different gateway addresses.
- The show ip route command displays the ECMP set:
router(config)#router isis 13
router(config-router)#maximum-paths 4
router(config-router)#exit
router(config)#ip route 17.17.17.0 255.255.255.0 10.10.10.1
router(config)#ip route 17.17.17.0 255.255.255.0 20.20.20.1
router(config)#ip route 17.17.17.0 255.255.255.0 30.30.30.1
router(config)#ip route 17.17.17.0 255.255.255.0 40.40.40.1
router(config)#end
router>show ip route
.
.
.
S 17.17.17.0/24 via 10.10.10.1 [w:1 m:0]
and 20.20.20.1
and 30.30.30.1
and 40.40.40.1
.
.
.
Related Commands: show ip route
Copyright © 2004
Avici Systems Inc.
Avici® and TSR®
is a registered trademark of Avici Systems Inc.
IPriori, Composite Links, SSR, QSR, and NSR® are
trademarks of Avici Systems Inc.
Source
File Name: IP_Commands.fm
HTML File Name: IP_Commands9.html
Last Updated: 05/10/04 at 16:34:20