Wednesday, 5 November 2014

How to do Linux routing !basics

Linux routing basics



Most of the people doesn’t know that linux/*nix systems can be used as routers. Even there is a project called Linux routing and separate Linux OS for routing purpose alone, that’s the flexibility of Linux. In linux/*nix every work can be done in two ways.
That is one temporary way(after reboots these changes will not be there) and
the other is permanent way(after reboots too the changes will be there).
Creating routes in Linux : Basic Linux routing 
Add a route to a network
#route add -net network/mask gw default-gateway 

Example 

#route add -net 10.10.10.0/24 gw 192.168.0.1

Or

#route add 10.10.10.1 gw 192.168.0.1
Adding default gateway
#route add default gw default-gateway
Example 
#route add default gw 192.168.0.1 
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.1Or

#route add 2.34.5.6 gw 192.168.0.1
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
Deleting default gateway
#route del default gw default-gatway
Example :
#route del default gw 192.168.0.1
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
Seeing routing table
#netstat -rn
#route -n 
Note : The old gate way will still remain and may need to be taken out for the system to function properly. Routes are made permanent in Red Hat Linux by adding routes to/etc/sysconfig/static-routes.

No comments:

Post a Comment