Defining Static Routes


Additional Static routes are defined by the route command.   It allows anyone to display the routing table and allows the root user to add and delete routes in the table.   sample code belows shows how to add a route to the existing table and as follows;


   route add -net 172.16.50.1

   netmask 255.255.255.0

   gw 172.16.55.34



Note

 

  • The -net option tells route that you are adding a network route.
  • The alternative is -host for a host-specific route, but this is rarely used because most routes are network routes
  • The -net option is followed by the destination address and by the network mask that is used to determine the network portion.   The network mask must be preceded by the keyword netmask 

Default Route

 

most Linux systems connected to a TCP/IP internet have a static default route.   Because it is so common, it is unlikely that you need to enter a route command to define it.   Red Hat stores the default gateway address in the /etc/sysconfig/network file.


  ex.: 


      route add default gw 172.16.55.253