Route for Linux was originally written by Fred N. van Kempen, Route manipulates the kernel's IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig(8) program.
To add a Static Route in Solaris you need use route command this will manipulates the Kernel's IP Routing Tables.
If you reboot the server the dynamic route will be lost to avoid this happening in future just create a script to start it in one of the /etc/rcX.d directories such as
/etc/rc2.d or /etc/rc3.d something like S99route.
Method (1)
Syntax:
root@techgyaan:~# route add [net|host] netmask [GatewayAddr|-interface ] Example:
root@techgyaan:~# route add -net 192.56.76.0 netmask 255.255.255.0 192.56.76.1or
root@techgyaan:~# route add -net 192.56.76.0/24 192.56.76.1to check the route
root@techgyaan:~# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags Mss Window irtt Iface
192.56.76.0 192.56.76.1 255.255.255.0 U 1 273 hme0
169.254.0.0 0.0.0.0 255.255.0.0 U 1 0 hme0To make this entires permanent next time you reboot your machine "route add" under /etc/rc2.d or /etc/rc2.d S99route startup file.
root@techgyaan:~# vi /etc/rc2.d/S99route
#/bin/sh
route add -net 192.56.76.0 netmask 255.255.255.0 192.56.76.1save & close the file
set the file to executable for owner, set owner as root. Now when you reboot, your route gets added
root@techgyaan:~# chmod 744 /etc/rc2.d/S99routePremission
### String Owner's Permissions Group's Permissions Other'sPermissions
744 -rwxr--r-- Read,Write & Execute Read Read
Method (2)
This method is just smiple.
Just create file under /etc/defaultrouter
/etc/defaultrouter is configuration file containing the hostnames or IP adresses of one or more default routers.
to check present routing table.
Syntax:
root@techgyaan:~# netstat -rn (netstat - show network status)Create file /etc/defaultrouter
root@techgyaan:~# touch /etc/defaultrouterroot@techgyaan:~# vi /etc/defaultrouter
192.56.76.1Save & close the file.
Fore more details on above commands refer man:
man route
man netstat
man defaultrouter
man chmod
Comments
Post a Comment