Adding a Default Route

Team-Fly    

Solaris™ Operating Environment Boot Camp
By David Rhodes, Dominic Butler
Table of Contents
Chapter 13.  Connecting to the Internet


Now we need to create the route itself. To do this dynamically, we can use the route command, just as we did for adding the routes between our subnets. But this time we use the "default" keyword to signify that this is the default route:

 xenon# route add default 172.35.63.1 1 xenon# 

Checking with netstat will show that the routes have now been created: the first to the network that the default route is connected to, and the second to the default router itself. It's always worth remembering that we must have a route to and from the default router!

 xenon# netstat -rn Routing Table:   Destination      Gateway        Flags  Ref   Use   Interface ---------------- ---------------- ----- ----- ------ --------- 192.168.22.0     192.168.22.50    U        3      5  hme0 192.168.44.0     192.168.44.51    U        3      5  hme0 172.35.63.0      172.35.63.51     U        2      1  hme1 default          172.35.63.1      UG       3      5 127.0.0.1        127.0.0.1        UH       0      2  lo0 xenon# 

To ensure that this is added whenever we boot the machine, we could add the above route command to the script named /etc/init.d/routes that we created in Chapter 11, "Connecting to the Local Area Network." The easier and most widely used method, though, is to create a file named /etc/defaultrouter and add the IP address of the router to it:

 xenon# cat /etc/defaultrouter 172.35.63.1 xenon# 

At boot-time, the system will check for the existence of this file and automatically create the route for us.

Host Names or Addresses

The defaultrouter file can contain either a host name or an IP address; we have decided to use IP addresses. The reason for this is that if host names are used, the system must be able to resolve them (i.e., determine their IP address), and communicate with them early in the boot processnormally before any additional routes have been configured, which means they must be in the local hosts file. By using addresses, we are sure we won't forget to update the hosts file and cause ourselves any problems.


    Team-Fly    
    Top
     



    Solaris Operating Environment Boot Camp
    Solaris Operating Environment Boot Camp
    ISBN: 0130342874
    EAN: 2147483647
    Year: 2002
    Pages: 301

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