Thursday, October 13, 2011

How To Setup\Change DNS Name Servers or Hostname in Linux

The file to chanage or edit your Name Servers in linux is:

vi /etc/resolv.conf


Now save the file and restart your network 


/etc/init.d/networking restart





To setup the hostname in debian use these steps

for example i will be using ns1.domain.com as my hostname and domain with ip of 192.168.0.101

firs step to do is to edit /etc/hosts
nano /etc/hosts

it will look something like this:
127.0.0.1 localhost.localdomain localhost ns1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


now change it to look like this:
127.0.0.1 localhost.localdomain localhost ns1
192.168.0.101 ns1.domain.com ns1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


I basically added this second line: 192.168.0.101 ns1.domain.com ns1

after you have made the changes send these two commands:

Command:
echo ns1.domain.com > /etc/hostname


Command:
/bin/hostname -F /etc/hostname

No comments:

Post a Comment