Monday, May 11, 2009

Setting the Default Gateway on SunOS

Setting the default gateway in Sun's OS is different than any other system I have used. If the gateway isn't set using the means below, it will default to using the local interface as the default gateway. This works fine if everything is on the same subnet.

I handle this in two steps, setting the default gateway instantly and setting the default gateway to be active upon reboot. Otherwise, to only create the /etc/defaultrouter file would require that the system reboot before it becomes active.

To view the current settings use

netstat -nr

To set the gateway to be active immediately:

route add default X.X.X.X

To set the gateway to active upon reboot:

vi /etc/defaultrouter

add a line with the IP address of the default gateway

On SunOS (by default) the gateway is set during run level 2 using the /etc/rc2.d/S69inet script. This script specifically looks for the existence of the /etc/defaultrouter file.

No comments: