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