This feature enables you to create static routes (and null routes) by adding such routes directly to the route table. This section describes how to add static and null routes to the IP route table.
You can configure the following types of static IP routes:
Standard |
The static route consists of a destination network address or host, a corresponding network mask, and the IP address of the next-hop IP address. |
Null (discard) |
The null route consists of the destination network address or host, a corresponding network mask, and either the This route is for all traffic to the "loopback" network, with the single exception of traffic to the host address of the switch's loopback interface (127.0.0.1/32.) Displaying the currently configured static routes shows the default null route entry in the switch's routing table. |
|
|
NOTE: On a single routing switch you can create one null route to a given destination. Multiple null routes to the same destination are not supported. |
|
|
The IP route table can also receive routes from the following sources:
-
Directly connected networks: One route is created per IP interface. When you add an IP interface, the routing switch automatically creates a route for the network the interface is in.
-
RIP: If RIP is enabled, the routing switch can learn about routes from the advertisements other RIP routers send to the routing switch. If the RIP route has a lower administrative distance than any other routes from different sources to the same destination, the routing switch places the route in the IP route table. See Administrative distance.
-
Default route: This is a specific static route that the routing switch uses if other routes to the destination are not available. See Configuring the default route.
When you configure a static IP route, you must specify the following parameters:
-
The IP address and network mask for the route's destination network or host.
-
The route's path, which can be one of the following:
The routing switch also applies default values for the route's administrative distance (Administrative distance). In the case of static routes, this is the value the routing switch uses to compare a static route to routes from other route sources to the same destination before placing a route in the IP route table.
The default administrative distance for static IP routes is 1, but can be configured to any value from 1 to 255.
The fixed administrative distance values ensure that the routing switch always prefers static IP routes over routes from other sources to the same destination.
IP static routes remain in the IP route table only so long as the IP interface to the next-hop router is up. If the next-hop interface goes down, the software removes the static route from the IP route table. If the next-hop interface comes up again, the software adds the route back to the route table.
This feature allows the routing switch to adjust to changes in network topology.
The routing switch does not continue trying to use routes on unreachable paths, but instead uses routes only when their paths are reachable.
For example, the following command configures a static route to 207.95.7.0 (with a network mask of 255.255.255.0), using 207.95.6.157 as the next-hop router's IP address:
A static IP route specifies the route's destination address and the next-hop router's IP address or routing switch interface through which the routing switch can reach the destination. (The route is added to the routing switch's IP route table.)
In the above example, routing switch "A" knows that 207.95.6.157 is reachable through port A2, and assumes that local interfaces within that subnet are on the same port. Routing switch "A" deduces that IP interface 207.95.7.188 is also on port A2. The software automatically removes a static route from the route table if the next-hop VLAN used by that route becomes unavailable. When the VLAN becomes available again, the software automatically re-adds the route to the route table.
Static route |
Configure a static route to a specific network or host address |
Null route |
Configure a "null" route to discard IP traffic to a specific network or host address: |
Syntax:
[no]
ip route <
dest-ip-addr
>/<mask-length
> <next-hop-ip-addr
|vlan <vlan-id
>|reject|blackhole> [metric <metric
>] [distance <1-255>] [tag-value <tagval
>]Allows the addition and deletion of static routing table entries. A route entry is identified by a destination (IP address/mask length) and next-hop pair. The next-hop can be either a gateway IP address, a VLAN, or the keyword "reject" or "blackhole".
A gateway IP address does not have to be directly reachable on one of the local subnets. If the gateway address is not directly reachable, the route is added to the routing table as soon as a route to the gateway address is learned.
<
dest-ip-addr>/<mask-bits
>The route destination and network mask length for the destination IP address. Alternatively, you can enter the mask itself.
For example, you can enter either 10.0.0.0/24 or 10.0.0.0 255.255.255.0 for a route destination of 10.0.0.0 255.255.255.0.
next-hop-ip-addr
This IP address is the gateway for reaching the destination. The next-hop IP address is not required to be directly reachable on a local subnet. (If the next-hop IP address is not directly reachable, the route will be added to the routing table as soon as a route to this address is learned.)
reject
Specifies a null route where IP traffic for the specified destination is discarded and an ICMP error notification is returned to the sender.
blackhole
Specifies a null route where IP traffic for the specified destination is discarded and no ICMP error notification is returned to the sender.
metric
Specifies an integer value that is associated with the route. It is used to compare a static route to routes in the IP route table from other sources to the same destination.
distance
Specifies the administrative distance to associate with a static route. If not specified, this value is set to a default of 1. (Range: 1 to 255)
tag
Specifies a unique integer value for a given ECMP set (destination, metric, distance.)
The
no
form of the command deletes the specified route for the specified destination next-hop pair.
The following example configures two static routes for traffic delivery and identifies two other null routes for which traffic should be discarded instead of forwarded.
Configuring static routes
HP Switch(config)# ip route 10.10.40.0/24 10.10.10.1 HP Switch(config)# ip route 10.10.50.128/27 10.10.10.1 HP Switch(config)# ip route 10.10.20.177/32 reject HP Switch(config)# ip route 10.10.30.0/24 blackhole
The show ip route
command displays the current static route configuration on the routing switch. Displaying the currently configured static routes shows the configuration resulting from the static routes configured in the previous examples.
You can also assign the default route and enter it in the routing table. The default route is used for all traffic that has a destination network not reachable through any other IP routing table entry. For example, if 208.45.228.35 is the IP address of your ISP router, all non-local traffic could be directed to the ISP by entering this command: