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  

 #route add -net network/mask gw default-gateway
 #route add -net gw
Example2: Adding default gateway  
 #route add default gw default-gateway
 #route add default gw
Example3: Adding a route to specific host
 #route add -host host-name gw default-gateway
 #rotue add -host gw
Ecample4: Deleting route to a network
 #route del -network network/subnet default-gateway
 #route del -net gw
Example5: Deleting default gateway
 #route del default gw default-gateway
 #route del default gw
Example6: Deleting specific host from routing table
 #route del -host ip-add gw default-gateway
 #route del -host gw
Example7: Seeing routing table
 #netstat -rn 

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
          #route add net 1.9..9.1

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

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

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

  • 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 1 -netmask

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
/usr/sbin/route add net     1
/usr/sbin/route add net     1

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


Popular posts from this blog

How to install Ansible on RHEL8 / CentOS8

Install and Use Stratis to Manage Local Storage on RHEL8/CentOS8

How to install Ansible Tower on Red Hat / CentOS