Tuesday, April 10, 2007

DNS Settings for internet

These are a set of steps one must go through before using the internet on Solaris. Since I have done these steps several times, each time forgetting something or the other, I feel it would be useful to have them documented in one common location. I am sure they have been documented elsewhere, but here they are nonetheless.

The following steps assume that you have a static local ip address, and you know your dns server settings as well as what your default gateway should be. If you need to setup your ip address, it can be done using the ifconfig .

eg :

ifconfig pcn0 192.168.2.100

to set interface pcn0 to ip address 192.168.2.100

There are other options as well for which you can consult the man pages for ifconfig.

man ifconfig


  1. Create a file called /etc/resolv.conf its contents should be :
nameserver 192.168.2.1
nameserver 192.168.2.2

Where 192.168.2.1 and 192.168.2.2 are your primary and secondary dns servers.

2. Either copy /etc/nsswitch.dns to /etc/nsswitch.conf

or
edit /etc/nsswitch.conf to change the line that says

hosts: file to hosts: file dns

3. Add a default route or gateway using the following command:

route add 192.168.2.254 0.0.0.0

Where 192.168.2.254 is your default gateway.

At this point you should be able to access the internet using hostnames rather than ip addresses. ie: your DNS settings should be working now.