How to change DNS servers

In both linux and Solaris and possibly other UNIX’es you can change your DNS servers simply by editing your /etc/resolv.conf

It should look like below.

search domain.com otherdomain.com
nameserver 192.168.0.1
nameserver 192.168.0.2

The nameserver’s or DNS server will try to be connected to in order from top to bottom. The search domains do not matter if they are at the top or bottom. Search domains are usefull if you dont want to have to type in the whole FQDN (Fully Qualified Domain Name). So instead of typing in “ping sparky.domain.com” you can shorten it to “ping sparky”.