Route for Linux was originally written by Fred N. van Kempen, and then modified by Johannes Stille and Linus Torvalds for pl15. Alan Cox added the mss and window options for Linux 1.1.22. irtt support and merged with netstat from Bernd Eckenfels.

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.1
or
root@techgyaan:~# route add -net 192.56.76.0/24 192.56.76.1

to 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 hme0

To 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.1

save & 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/S99route

Premission
### 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/defaultrouter
root@techgyaan:~# vi /etc/defaultrouter
192.56.76.1

Save & close the file.

Fore more details on above commands refer man:
man route
man netstat
man defaultrouter
man chmod

Feedbacks: We appreciate feedbacks and suggestions about our website info@techgyaan.org

Your Ad Here