System Administration Guide: IP Services

Routing Tables and Routing Types

Both routers and hosts maintain a routing table. The routing daemon on each system updates the table with all known routes. The system's kernel reads the routing table before forwarding packets to the local network. The routing table lists the IP addresses of networks that the system knows about, including the system's local, default network. The table also lists the IP address of a gateway system for each known network. The gateway is a system that can receive outgoing packets and forward them one hop beyond the local network. The following is a simple routing table for a system on an IPv4-only network:

Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
default              UG       1    532   ce0             U        1      0   bge0              U        1      0   bge0              UH       1     57   lo0

You can configure two types of routing on an Oracle Solaris system: static and dynamic. You can configure either or both routing types on a single system. A system that implements dynamic routing relies on routing protocols, such as RIP for IPv4 networks, and RIPng for IPv6 networks, to maintain its routing tables. A system that runs only static routing does not rely on a routing protocol for routing information and for updating the routing table. Instead, you must maintain the system's known routes manually through the route command. For complete details, refer to the route(1M) man page.

When you configure routing for the local network or autonomous system, consider which type of routing to support on particular routers and hosts.

The following table shows the different types of routing and the networking scenarios to which each routing type is best applied.

Routing Type 

Best Used on 


Small networks, hosts that get their routes from a default router, and default routers that only need to know about one or two routers on the next few hops.


Larger internetworks, routers on local networks with many hosts, and hosts on large autonomous systems. Dynamic routing is the best choice for systems on most networks.

Combined static and dynamic 

Routers that connect a statically routed network and a dynamically routed network, and border routers that connect an interior autonomous system with external networks. Combining both static and dynamic routing on a system is a common practice. 

The AS that is shown is Figure 5–3 combines both static and dynamic routing.

Configuring Routes

To implement dynamic routing for an IPv4 network, use the routeadm or svcadm command to start the in.routed routing daemon. For instructions, see How to Configure an IPv4 Router. Dynamic routing is the preferred strategy for most networks and autonomous systems. However, your network topology or a particular system on your network might require static routing. In that case, you must manually edit the system routing table to reflect the known route to the gateway. The next procedure shows how to add a static route.

Note –

Two routes to the same destination does not automatically cause the system to do load balancing or failover. If you need these capabilities, use IPMP, as explained in Chapter 30, Introducing IPMP (Overview).

ProcedureHow to Add a Static Route to the Routing Table

  1. View the current state of the routing table.

    Use your regular user account to run the following form of the netstat command:

    % netstat -rn

    Your output would resemble the following:

    Routing Table: IPv4
      Destination           Gateway           Flags  Ref   Use   Interface
    -------------------- -------------------- ----- ----- ------ ---------          U      1   5879   ipge0            U      1  0       ipge0
    default              UG     1  91908               UH     1  811302   lo0
  2. Assume the Primary Administrator role or become superuser.

    The Primary Administrator role includes the Primary Administrator profile. To create the role and assign the role to a user, see Chapter 2, Working With the Solaris Management Console (Tasks), in System Administration Guide: Basic Administration.

  3. (Optional) Flush the existing entries in the routing table.

    # route flush
  4. Add a route that persists across system reboots.

    # route -p add -net network-address -gateway gateway-address

    Creates a route that must persist across system reboots. If you want the route to prevail only for the current session, do not use the -p option.


    Indicates that you are about to add the following route.

    -net network-address

    Specifies that the route goes to the network with the address in network-address.

    -gateway gateway-address

    Indicates that the gateway system for the specified route has the IP address gateway-address.

Example 5–5 Adding a Static Route to the Routing Table

The following example shows how to add a static route to a system. The system is Router 2, the default router for the network that is shown in Figure 5–3. In Example 5–4, Router 2 is configured for dynamic routing. To better serve as the default router for the hosts on network, Router 2 additionally needs a static route to the AS's border router,

To view the routing table on Router 2, you would do the following:

# netstat -rn
Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
default              UG        1    249 ce0            U         1      0 ce0               U         1     78 bge0              UH        1     57 lo0

The routing table indicates two routes that Router 2 knows about. The default route uses Router 2's interface as its gateway. The second route,, was discovered by the in.routed daemon running on Router 2. The gateway for this route is Router 1, with the IP address

To add a second route to network, which has its gateway as the border router, you would do the following:

# route -p add -net -gateway
add net gateway

Now the routing table has a route for the border router, which has the IP address

# netstat -rn
Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
default              UG        1    249 ce0            U         1      0 ce0               U         1     78 bge0              U         1    375 bge0              UH        1     57 lo0