System Administration Guide: IP Services

Configuring Routing for Single-Interface Systems

Single-interface hosts need to implement some form of routing. If the host is to obtain its routes from one or more local default routers, then you must configure the host to use static routing. Otherwise, dynamic routing is recommended for the host. The following procedures contain the instructions for enabling both routing types.

ProcedureHow to Enable Static Routing on a Single-Interface Host

This procedure enables static routing on a single-interface host. Hosts that use static routing do not run a dynamic routing protocol such as RIP. Instead, the host must rely on the services of a default router for routing information. The figure IPv4 Autonomous System Topology shows several default routers and their client hosts. If you supplied the name of a default router when you installed a particular host, that host is already configured to use static routing.


Note –

You can also use the following procedure to configure static routing on a multihomed host.


For information about the /etc/defaultrouter file, see /etc/defaultrouter File. For information about static routing and the routing table, refer to Routing Tables and Routing Types.

  1. On the single interface host, 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.

  2. Verify whether the /etc/defaultrouter file is present on the host.


    # cd /etc
    # ls | grep defaultrouter
    
  3. Open a text editor to create or modify the /etc/defaultrouter file

  4. Add an entry for the default router.


    # vi  /etc/defaultrouter
    router-IP
           
    

    where router-IP indicates the IP address of the default router for the host to use.

  5. Verify that routing and packet forwarding are not running on the host.


    # routeadm
       Configuration   Current              Current
                         Option   Configuration        System State
    ---------------------------------------------------------------
                   IPv4 routing   disabled             disabled
                   IPv6 routing   disabled             disabled
                IPv4 forwarding   disabled            disabled
                IPv6 forwarding   disabled             disabled
    
               Routing services   "route:default ripng:default"
  6. Add an entry for the default router in the local /etc/inet/hosts file.

    For information about configuring /etc/inet/hosts, refer to How to Change the IPv4 Address and Other Network Configuration Parameters.


Example 5–7 Configuring a Default Router and Static Routing for a Single-Interface Host

The following example shows how to configure static routing for hostb, a single-interface host on the network 172.20.1.0 that is shown in Figure 5–3. hostb needs to use Router 2 as its default router.

First, you would log in to hostb as superuser, or assume an equivalent role. Then, you would determine whether the /etc/defaultrouter file is present on the host:


# cd /etc
# ls | grep defaultrouter

No response from grep indicates that you need to create the /etc/defaultrouter file.


# vi /etc/defaultrouter
172.20.1.10

The entry in the /etc/defaultrouter file is the IP address of the interface on Router 2, which is attached to the 172.20.1.0 network. Next, you verify whether the host currently enables packet forwarding or routing.


# routeadm
   Configuration   Current              Current
                     Option   Configuration        System State
---------------------------------------------------------------
               IPv4 routing   disabled             disabled
               IPv6 routing   disabled             disabled
            IPv4 forwarding   enabled              enabled
            IPv6 forwarding   disabled             disabled

           Routing services   "route:default ripng:default"

Packet forwarding is enabled for this particular host. You would turn it off as follows:


# svcadm disable ipv4-forwarding

Lastly, you would make sure that the host's /etc/inet/hosts file has an entry for the new default router.


# vi /etc/inet/hosts
127.0.0.1           localhost
172.20.1.18         host2    #primary network interface for host2
172.20.1.10         router2  #default router for host2

ProcedureHow to Enable Dynamic Routing on a Single-Interface Host

Dynamic routing is the easiest way to manage routing on a host. Hosts that use dynamic routing run the routing protocols provided by the in.routed daemon for IPv4 or in.ripngd daemon for IPv6. Use the next procedure to enable IPv4 dynamic routing on a single interface host. For more information about dynamic routing, refer to Packet Forwarding and Routing on IPv4 Networks.

  1. On the host, 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.

  2. Verify whether the /etc/defaultrouter file exists.


    # cd /etc
    # ls | grep defaultrouter
    
  3. If /etc/defaultrouter exists, delete any entry that you find there.

    An empty /etc/defaultrouter file forces the host to use dynamic routing.

  4. Verify whether packet forwarding and routing are enabled on the host.


    # routeadm
       Configuration   Current              Current
                         Option   Configuration        System State
    ---------------------------------------------------------------
                   IPv4 routing   disabled             disabled
                   IPv6 routing   disabled             disabled
                IPv4 forwarding   enabled              enabled
                IPv6 forwarding   disabled             disabled
    
               Routing services   "route:default ripng:default"
  5. If packet forwarding is enabled, turn it off

    Use either of the following commands:

    • For the routeadm command, type the following:


      # routeadm -d ipv4-forwarding -u
      
    • To use SMF, type the following:


      # svcadm disable ipv4-forwarding
      
  6. Enable routing protocols on the host.

    Use either of the following commands:

    • For the routeadm command, type the following:


      # routeadm -e ipv4-routing -u
      
    • To use SMF, type the following:


      # svcadm enable route:default
      

    Now IPv4 dynamic routing is enabled. The host's routing table is dynamically maintained by the in.routed daemon.


Example 5–8 Running Dynamic Routing on a Single-Interface Host

The following example shows how to configure dynamic routing for hosta, a single-interface host on the network 192.168.5.0 that is shown in Figure 5–3. hosta currently uses Router 1 as its default router. However, hosta now needs to run dynamic routing.

First, you would log in to hosta as superuser or assume an equivalent role. Then, you would determine whether the /etc/defaultrouter file is present on the host:


# cd /etc
# ls | grep defaultrouter
defaultrouter

The response from grep indicates that a /etc/defaultrouter file exists for hosta.


# vi /etc/defaultrouter
192.168.5.10

The file has the entry 192.168.5.10, which is the IP address for Router 1. You would delete this entry to enable static routing. Next, you would need to verify whether packet forwarding and routing are already enabled for the host.


# routeadm   Configuration   Current              Current
                     Option   Configuration        System State
---------------------------------------------------------------
               IPv4 routing   disabled             disabled
               IPv6 routing   disabled             disabled
            IPv4 forwarding   disabled             disabled
            IPv6 forwarding   disabled             disabled

           Routing services   "route:default ripng:default"

Both routing and packet forwarding are turned off for hosta. Turn on routing to complete the configuration of dynamic routing for hosta, as follows:


# svcadm enable route:default