Static Route Configuration


Static routes are permanent entries that do not change. They can be configured in two ways: manually by using the route command, or through the use of two configuration files, /etc/defaultrouter and /etc/gateways . This section covers the use of the route command. The configuration files are discussed later in this chapter.

The route Command

The route command is used to manipulate the routing table manually. Routes can be added, deleted, and changed with this command. The general format of the route command is

 route add  delete  change <  destination  > <  gateway  > 

where < destination > is the host or network you are trying to reach and < gateway > is the router that will forward the packet to the destination.

graphics/alert_icon.gif

The routing table can be flushed of all entries if you use the route command with the flush option as follows :

 ultra10# route flush 

The same can also be achieved by adding the -f option to the route command.


Figure 6.1 shows a sample configuration with three networks, connected through the use of two routers, which are used here to illustrate static routes.

Figure 6.1. A sample network configuration using routers.

graphics/06fig01.gif

Notice that the hosts on network A can communicate with hosts on network B or network C, only if they use router 1 as an intermediate gateway. The connection to network C is not so apparent because it relies on router 1 forwarding data to router 2 ”that is, it would take three hops for a host on network A to communicate with a host on network C, namely host on network A to router 1, router 1 to router 2, and router 2 to host on network C.

Also, the hosts on network B can communicate with hosts on network A only if they use router 1 as an intermediate gateway. Similarly, the hosts on network B can communicate with hosts on network C only if they use router 2 as an intermediate gateway.

If a host were to be added to network B, for example, then a static route would be added for both network A and network C, using router 1 and router 2 as gateways, respectively. The commands to add these routes would be

 ultra10# route add 192.168.28.0 192.168.29.1 add net 192.168.28.0: gateway 192.168.29.1 ultra10# route add 192.168.30.0 192.168.29.2 add net 192.168.30.0: gateway 192.168.29.2 

When a host on network B sends a packet to a host on network A for example, it is passed to the router interface 192.168.29.1 for delivery. If the same host on network B sends a packet to a host on network C, it is passed to the router interface 192.168.29.2 for delivery.

To delete the route to the network 192.168.30.0 , enter the following command:

 ultra10# route delete 192.168.30.0 192.168.29.2 delete net 192.168.30.0: gateway 192.168.29.2 

If the route to network A changes from 192.168.29.1 to 192.168.29.55 , for example, enter the following command to modify the route:

 ultra10# route change 192.168.28.0 192.168.29.55 change net 192.168.28.0: gateway 192.168.29.55 

For hosts on network A, all communications will pass through router 1, using the IP address 192.168.28.1 , so it would be easier to create a default route as follows:

 ultra10# route add default 192.168.28.1 add net default: gateway 192.168.28.1 
graphics/alert_icon.gif

Static routes created with the route command at the command line are permanent entries, but do not exist across reboots of the system. If static routes are required to persist across reboots, then use the configuration files /etc/defaultrouter (for a default static route) or /etc/gateways (for other static routes). Alternatively, create a startup script containing the route commands, which will be executed each time the system reboots.


The route monitor command can be used see any changes that are made to the routing table. When you run this command, it informs you straight away of the changes. The following example code shows the addition and subsequent deletion of a route.

 ultra10# route monitor got message of size 124 RTM_ADD: Add Route: len 124, pid: 368, seq 1, errno 0, flags:<UP,GATEWAY, \ DONE,STATIC> locks:  inits: sockaddrs: <DST,GATEWAY,NETMASK>  192.168.28.0 192.168.29.1 255.255.255.0 got message of size 124 RTM_DELETE: Delete Route: len 124, pid: 369, seq 1, errno 0, flags:<UP, \ GATEWAY,DONE,STATIC> locks:  inits: sockaddrs: <DST,GATEWAY,NETMASK>  192.168.28.0 192.168.29.1 255.255.255.0 

The manipulation of routing table entries can become quite complex when you have to deal with numerous IP addresses. A simpler way of doing this is to use the /etc/inet/networks file to assign names to the networks and the /etc/inet/hosts file to assign names to the router interfaces.

In the previous examples, you could add the following entries to /etc/inet/networks :

 networkA    192.168.28.0 networkB    192.168.29.0 networkC    192.168.30.0 

and add the following entries to /etc/inet/hosts :

 192.168.28.1    routerA 192.168.29.1    routerBtoA 192.168.29.2    routerBtoC 192.168.30.1    routerC 

Now, to add the route from a host on network B to any host on network A, use the following route command:

 ultra10# route add networkA routerBtoA add net networkA: gateway routerBtoA 

Configuration Files

Two configuration files can be used to assign static routes: /etc/defaultrouter and /etc/gateways . Both of these files are described in this section:

  • /etc/defaultrouter ” This file normally contains a single IP address or hostname that identifies the default path that data should take when being transmitted across the network. The default route is used when no other specific route is identified for the destination. Hostnames can be used only if the relevant entry exists in the /etc/inet/hosts file. Although this file usually contains only one entry, multiple entries are permitted, one per line.

    The use of default routes has some distinct advantages. These are

    • The existence of the /etc/defaultrouter file stops the routing daemon ( in.routed ) and the dynamic router discovery daemon ( in.rdisc ) from starting when the system is booting. The startup script /etc/rc2.d/S69inet contains the check for the existence of the /etc/defaultrouter file.

    • Using a single default route entry reduces the processing overhead because the routing table is smaller.

    • Using multiple default route entries adds some resilience so that a potential single point of failure is avoided.

    The use of default routes, however, has a few disadvantages, too:

    • When using a single default route entry, a single point of failure is created, impacting the network connectivity if the default router becomes unavailable.

    • The /etc/defaultrouter file must be present on every system. You can't use a naming service to manage this file centrally because it is read during the system startup process, before any naming service processes are running. On larger networks that change frequently, management of /etc/defaultrouter can incur a significant administration overhead.

  • /etc/gateways ” This file is an optional file that is read at system startup when the routing daemon ( in.routed ) starts up. It provides an alternative way of adding static routes. Each entry in the /etc/gateways file has the following format:

     net  host <  destination  > gateway <  gateway  > metric <  hopcount  > passive  active 

The fields are described here:

  • net host ” Using either net or host will identify whether the route is to a specific host or to a network. This precedes the address or name or the destination host or network.

  • < destination > ” The IP address, (or hostname or network name) of the destination, either a host or a network.

  • gateway ” This precedes the address, or name, of the gateway to be used.

  • < gateway > ” The IP address or hostname or the router to be used as the gateway.

  • metric ” This precedes the < hopcount > value.

  • < hopcount > ” The number of hops taken to reach the destination.

  • passive active ” Use either passive for a static route or active for a dynamic route.

A typical entry for the /etc/gateways file that adds a static route to the network networkA via the router routerA , which takes two hops, is shown here:

 net networkA gateway routerA metric 2 passive 


Solaris 9 Network Administration Exam Cram 2 (Exam Cram CX-310-044)
Solaris 9 Network Administrator Exam Cram 2 (Exam CX-310-044)
ISBN: 0789728702
EAN: 2147483647
Year: 2003
Pages: 174
Authors: John Philcox

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net