Linux and Solaris Routing Basics
Creating routes in Linux: Basic Linux routingDo 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-gatewayExample
#route add -net 10.10.10.0/24 gw 192.168.0.1Example2: Adding default gateway
#route add default gw default-gatewayExample
#route add default gw 192.168.0.1Example3: Adding a route to specific host
#route add -host host-name gw default-gatewayExample:
#rotue add -host 22.214.171.124 gw 192.168.0.1Ecample4: Deleting route to a network
#route del -network network/subnet default-gatewayExample
#route del -net 10.10.10.0/24 gw 192.168.0.1Example5: Deleting default gateway
#route del default gw default-gatewayExample:
#route del default gw 192.168.0.1Example6: Deleting specific host from routing table
#route del -host ip-add gw default-gatewayExample
#route del -host 10.10.10.45 gw 192.168.0.1Example7: Seeing routing table
#netstat -rn #routeNote: 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.
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 126.96.36.199 1.9..9.1
- Add a default route.
#route add default default-gateway
#route add default 188.8.131.52
- Delete a route
#route delete net network default-gateway
- Look-up and display the route for a destination network:
# route get destination-network
#route get 184.108.40.206
- 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 220.127.116.11 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 18.104.22.168 22.214.171.124 1
/usr/sbin/route add net 126.96.36.199 188.8.131.52 1
/usr/sbin/route add net 184.108.40.206 220.127.116.11 1
save the file and exit so from next time on words no need to execute the route commands every time after reboot.