Linux and Solaris Routing Basics

Creating routes in Linux: Basic Linux routing

Do you know that Linux OS can use as a router? We will see how to implement routing on Linux box here. When I am working for Cisco Systems they use Linux servers as routers in their test environments in order to communicate between routers in Lab environment. Even there is a project called Linux routing and a separate Linux flavor for routing purpose, that’s the flexibility of Linux. Let us start some basic routing commands. In Linux/*nix every work can be done in two ways.

1) That is a temporary way (after reboots these changes will not be there) and
2) The other is permanent way (after reboots too, the changes will be there).

We will see how to add routes temporary as well as permanent way today.


Example1: Add a route to network  

Syntax:

 #route add -net network/mask gw default-gateway

Example

 #route add -net 10.10.10.0/24 gw 192.168.0.1

Example2: Adding default gateway  
Syntax:

 #route add default gw default-gateway

Example

 #route add default gw 192.168.0.1

Example3: Adding a route to specific host

 #route add -host host-name gw default-gateway

Example:

 #rotue add -host 2.34.5.6 gw 192.168.0.1

Ecample4: Deleting route to a network

 #route del -network network/subnet default-gateway

Example

 #route del -net 10.10.10.0/24 gw 192.168.0.1

Example5: Deleting default gateway

 #route del default gw default-gateway

Example:

 #route del default gw 192.168.0.1

Example6: Deleting specific host from routing table

 #route del -host ip-add gw default-gateway

Example

 #route del -host 10.10.10.45 gw 192.168.0.1

Example7: Seeing routing table

 #netstat -rn 
#route

Note: The old gate way will still remain and may need to remove from the system to function properly. Routes are made permanent in Red hat Linux by adding routes to/etc/sysconfig/static-routes.

Solaris routing basics

This my first post on Solaris on my LinuxNIX(NIX is nothing but UNIX all flavors).
Creating routes in Solaris: Basic Sun Solaris  routing

  • Add a route to a network
    #route add net network default-gateway

Example
          #route add net 5.23.1.0 1.9..9.1

  • Add a default route.
    #route add default  default-gateway

Example
          #route add default 1.9.9.1

  • Delete a route
    #route delete net network default-gateway

Example           #route delete net 5.23.1.0 1.9.9.1

  • Look-up and display the route for a destination network:
    # route get destination-network

Example
          #route get 5.23.1.0

  • Get routing reports continuously
    # route monitor


  • Flushing the route table:
    # route flush


  • Seeing routing table in sun box
  • #netstat -nr
  • Use the “route add net” command with the -netmask option to make the route command to take the netmask specified on the command line # route add net 192.168.68.0 128.50.1.250 1 -netmask 255.255.255.192


Permanently assigning a routes in sun box
/etc/rc2.d/S69inet file can be used for routes to exits permanently Example entries in S69inet file
/usr/sbin/route add net         1.100.0.0       1.7.16.1     1
/usr/sbin/route add net         17.48.30.0      1.7.0.48     1
/usr/sbin/route add net         17.48.30.0      1.7.48.1     1


save the file and exit so from next time on words no need to execute the route commands every time after reboot.

Leave a Reply

Your email address will not be published. Required fields are marked *