When running a
routing protocol, the Ethernet switch also functions as a router. The word “router”
and the router icons covered in the following text represent routers in common sense
and Ethernet switches running a routing protocol. To improve readability, this
will not be mentioned again in this manual.
Routers are used for route selection on the
Internet. As a router receives a packet, it selects an appropriate route
(through a network) according to the destination address of the packet and
forwards the packet to the next router. The last router on the route is
responsible for delivering the packet to the destination host.
A route segment is a common physical
network interconnecting two nodes, which are deemed adjacent on the Internet. That
is, two routers connected to the same physical network are adjacent to each
other. The number of route segments between a router and any host on the local network
is zero. In the following figure, the bold arrows represent route segments. A
router is not concerned about which physical links compose a route segment. As
shown in Figure 1-1, a packet sent from Host A to Host C travels through two routers over three route segments (along the broken line).

Figure 1-1 Route
segment
The number of route segments on the path
between a source and destination can be used to measure the "length"
of the path. As the sizes of networks may differ greatly, the actual length of
router segments may be different from each other. Therefore, you can put
different weights to different route segments (so that, for example, a route
segment can be considered as two segments if the weight is two). In this way, the
length of the path can be measure by the number of weighted route segments.
If routers in networks are regarded as nodes
in networks and route segments in the Internet are regarded as links in the
Internet, routing in the Internet is similar to that in a conventional network.
Routing through the shortest route is not always the most ideal way.
For example, routing across three high-speed LAN route segments may be much
faster than routing across two low-speed WAN route segments.
The key for a router to forward packets is
the routing table. Each router maintains a routing table. Each entry in this
table contains an IP address that represents a host/subnet and specifies which
physical port on the router should be used to forward the packets destined for
the host/subnet. And the router forwards those packets through this port to the
next router or directly to the destination host if the host is on a network
directly connected to the router.
Each entry in a routing table contains:
l
Destination address: It identifies the address of
the destination host or network of an IP packet.
l
Network mask: Along with the destination
address, it identifies the address of the network segment where the destination
host or router resides. By performing “logical AND” between
destination address and network mask, you can get the address of the network
segment where the destination host or router resides. For example, if the
destination address is 129.102.8.10 and the mask is 255.255.0.0, the address of
the network segment where the destination host or router resides is
129.102.0.0. A mask consists of some consecutive 1s, represented either in
dotted decimal notation or by the number of the consecutive 1s in the mask.
l
Output interface: It indicates through which
interface IP packets should be forwarded to reach the destination.
l
Next hop address: It indicates the next router
that IP packets will pass through to reach the destination.
l
Preference of the route added to the IP routing
table: There may be multiple routes with different next hops to the same
destination. These routes may be discovered by different routing protocols, or
be manually configured static routes. The one with the highest preference (the
smallest numerical value) will be selected as the current optimal route.
According to different destinations, routes
fall into the following categories:
l
Subnet route: The destination is a subnet.
l
Host route: The destination is a host.
In addition, according to whether the network
where the destination resides is directly connected to the router, routes fall
into the following categories:
l
Direct route: The router is directly connected
to the network where the destination resides.
l
Indirect route: The router is not directly connected
to the network where the destination resides.
In order to avoid an oversized routing
table, you can set a default route. All the packets for which the router fails
to find a matching entry in the routing table will be forwarded through this
default route.
Figure 1-2 shows a relatively complicated internet environment, the number in
each network cloud indicate the network address and "R" represents a
router. The router R8 is connected to three networks, and so it has three IP
addresses and three physical ports. Its routing table is shown in Figure 1-2.

Figure 1-2 Routing table
The H3C S3100-52P Ethernet Switches (hereinafter referred to as S3100-52P)
support the configuration of static routes as well as a series of dynamic
routing protocols such as RIP and OSPF. Moreover, the switches in operation can
automatically obtain some direct routes according to interface status and user
configuration.
On an S3100-52P Ethernet switch, you can
manually configure a static route to a certain destination, or configure a dynamic
routing protocol to make the switch interact with other routers in the internetwork
and find routes by routing algorithm. On an S3100-52P Ethernet switch, the
static routes configured by the user and the dynamic routes discovered by
routing protocols are managed uniformly. The static routes and the routes
learned or configured by different routing protocols can also be shared among
routing protocols.
Different routing protocols may discover
different routes to the same destination, but only one route among these routes
and the static routes is optimal. In fact, at any given moment, only one
routing protocol can determine the current route to a specific destination. Routing
protocols (including static routing) are endowed with different preferences.
When there are multiple routing information sources, the route discovered by
the routing protocol with the highest preference will become the current route.
Routing protocols and their default route preferences (the smaller the value is,
the higher the preference is) are shown in Table 1-1.
In the table,
“0” is used for directly connected routes, and “255” is
used for routes from untrusted sources.
Table 1-1 Routing protocols and corresponding
route preferences
|
Routing protocol or route type
|
Preference of the corresponding route
|
|
DIRECT
|
0
|
|
OSPF
|
10
|
|
STATIC
|
60
|
|
RIP
|
100
|
|
OSPF ASE
|
150
|
|
OSPF NSSA
|
150
|
|
UNKNOWN
|
255
|
Except for direct routing, you can manually configure the
preferences of various dynamic routing protocols as required. In addition, you
can configure different preferences for different static routes.
I. Traffic sharing
The S3100-52P support multi-route mode,
allowing the configuration of multiple routes that reach the same destination
and have the same preference. The same destination can be reached through
multiple different routes, whose preferences are equal. When there is no route
with a higher preference to the same destination, the multiple routes will be
adopted. Then, the packets destined for the same destination will be forwarded through
these routes in turn to implement traffic sharing.
II. Route backup
The S3100-52P support route backup. When
the primary route fails, the system automatically switches to a backup route to
improve network reliability.
To achieve route backup, you can configure multiple routes to the
same destination according to actual situation. One of the routes has the
highest preference and is called primary route. The other routes have
descending preferences and are called backup routes. Normally, the router sends
data through the primary route. When line failure occurs on the primary route,
the primary route will hide itself and the router will choose the one whose
preference is the highest among the remaining backup routes as the path to send
data. In this way, the switchover from the primary route to a backup route is implemented.
When the primary route recovers, the router will restore it and re-select a route.
And, as the primary route has the highest preference, the router will choose
the primary route to send data. This process is the automatic switchover from
the backup route to the primary route.
Static routes are special routes. They are
manually configured by the administrator. By configuring static routes, you can
build an interconnecting network. The problem for such configuration is when a
fault occurs on the network, a static route cannot change automatically to
steer away from the fault point without the help of the administrator.
In a relatively simple network, you only
need to configure static routes to make routers work normally. Proper
configuration and usage of static routes can improve network performance and
ensure sufficient bandwidth for important applications.
Static routes are divided into three types:
l
Reachable route: normal route. If a static route
to a destination is of this type, the IP packets destined for this destination
will be forwarded to the next hop. It is the most common type of static routes.
l
Unreachable route: route with the "reject"
attribute. If a static route to a destination has the "reject"
attribute, all the IP packets destined for this destination will be discarded,
and the source hosts will be informed of the unreachability of the destination.
l
Blackhole route: route with “blackhole”
attribute. If a static route destined for a destination has the “blackhole”
attribute, the outgoing interface of this route is the Null 0 interface
regardless of the next hop address, and all the IP packets addressed to this
destination will be dropped without notifying the source hosts.
The attributes "reject"
and "blackhole" are usually used to limit the range of the
destinations this router can reach, and help troubleshoot the network.
A default route is a
special route. You can manually configure a default route by using a static
route. Some dynamic routing protocols, such as OSPF, can automatically generate
a default route.
Simply to say,
a default route is a route used only when no matching entry is found in the
routing table. That is, the default route is used only when there is no proper
route. In a routing table, both the destination address and mask of the default
route are 0.0.0.0. You can use the display ip routing-table command to
view whether the default route has been set. If the destination address of a packet
does not match any entry in the routing table, the router will select the
default route for the packet; in this case, if there is no default route, the
packet will be discarded, and an Internet control message protocol (ICMP)
packet will be returned to inform the source host that the destination host or
network is unreachable.
Before configuring a static route, perform
the following tasks:
l
Configuring the physical parameters of the
related interface
l
Configuring the link layer attributes of the
related interface
l
Configuring an IP address for the related
interface
Table 2-1
Configure a static route
|
Operation
|
Command
|
Description
|
|
Enter system view
|
system-view
|
—
|
|
Add a static route
|
ip route-static ip-address { mask | mask-length
} { interface-type interface-number | next-hop } [ preference
value ] [ reject | blackhole ] [ description text
| detect-group group number ]*
|
Required
By default, the system can obtain the
route to the subnet directly connected to the router.
|
|
Delete all static routes
|
delete static-routes all
|
Optional
This command deletes all static routes,
including the default route.
|
l
If the destination IP address and the mask of a
route are both 0.0.0.0, the route is the default route. Any packet for which the
router fails to find a matching entry in the routing table will be forwarded
through the default route.
l
Do not configure the next hop address of a
static route to the address of an interface on the local switch.
l
Different preferences can be configured to implement
flexible route management policy.
After the
above configuration, use the display command in any view to display and
verify the static route configuration.
Table 2-2
Display the routing table
|
Operation
|
Command
|
Description
|
|
Display routing
table summary
|
display ip routing-table
|
You can execute the display
command in any view.
|
|
Display routing
table details
|
display ip routing-table verbose
|
|
Display the detailed information of a
specific route
|
display ip routing-table ip-address [ mask ] [ longer-match
] [ verbose ]
|
|
Display the routes in a specified
address range
|
display ip routing-table ip-address1 mask1 ip-address2 mask2 [
verbose ]
|
|
Display the routes filtered through a specified basic access control list (ACL)
|
display ip routing-table acl acl-number [ verbose ]
|
|
Display the routes filtered through a specified IP prefix list
|
display ip routing-table ip-prefix ip-prefix-name [ verbose ]
|
|
Display the routes discovered by a specified
protocol
|
display ip routing-table protocol protocol [ inactive | verbose
]
|
|
Display the tree-structured routing table information
|
display ip routing-table radix
|
|
Display the statistics of the routing
table
|
display ip routing-table statistics
|
|
Clear statistics for the public routing
table
|
reset ip routing-table statistics
protocol { all | protocol }
|
You can execute the reset command
in user view
|
I. Network requirements
As shown in Figure 2-1, the masks of all the IP addresses in the figure are 255.255.255.0.
It is required that all the hosts/Ethernet switches in the figure can
interconnect with each other by configuring static routes.
II. Network diagram

Figure 2-1 Static route configuration
III. Configuration procedure
# Configure static routes on Switch A.
[Switch A] ip route-static 1.1.3.0
255.255.255.0 1.1.2.2
[Switch A] ip route-static 1.1.4.0
255.255.255.0 1.1.2.2
[Switch A] ip route-static 1.1.5.0
255.255.255.0 1.1.2.2
# Configure static routes on Switch B.
[Switch B] ip route-static 1.1.2.0
255.255.255.0 1.1.3.1
[Switch B] ip route-static 1.1.5.0
255.255.255.0 1.1.3.1
[Switch B] ip route-static 1.1.1.0
255.255.255.0 1.1.3.1
# Configure static routes on Switch C.
[Switch C] ip route-static 1.1.1.0
255.255.255.0 1.1.2.1
[Switch C] ip route-static 1.1.4.0
255.255.255.0 1.1.3.2
# Configure the default gateway of Host A
to 1.1.5.1.
[Switch A] ip route-static 0.0.0.0
0.0.0.0 1.1.5.1
# Configure the default gateway of Host B
to 1.1.4.1.
[Switch B] ip route-static 0.0.0.0
0.0.0.0 1.1.4.1
# Configure the default gateway of Host C
to 1.1.1.1.
[Switch C] ip route-static 1.1.1.0
255.255.255.0 1.1.1.1
Now, all the
hosts/switches in the figure can interconnect with each other.
Symptom: The switch is not configured with a
dynamic routing protocol. Both the physical status and the link layer protocol status
of an interface are UP, but IP packets cannot be normally forwarded on the
interface.
Solution: Perform the following procedure.
Use the display ip routing-table protocol
static command to view whether the corresponding static route is correctly
configured.
Use the display ip routing-table
command to view whether the static route is valid.