# changing DNS addresses

## grimx

how do i go about changing my DNS addressses that are listed in /etc/resolv.conf

permenantly ??

----------

## Stu_28

Assuming you are using DHCP, add nodns to the dhcp_eth0 variable in /etc/conf.d/net.

----------

## grimx

i tried that

i put this in my /etc/conf.d/net  file

dhcp_eth0="nodns"

and changed the nameserver ips in /etc/resolv.conf file

rebooted and i had no internet connection

----------

## Stu_28

You had no connection, or was your /etc/resolv.conf file empty?

----------

## grimx

it was empty

----------

## Stu_28

Maybe your DHCP client wipes /etc/resolv.conf when it shuts down.  Try editing the file after you start eth0 using nodns.

----------

## grimx

that seems to work, /etc/resolv.conf did not get cleared.

so how do i make the permenant??

----------

## Stu_28

If you restart it now that it works does it get wiped again?  It shouldn't...

----------

## grimx

it wiped it again.

when i did what u said previous, all i did was logout then login again.

----------

## grimx

i tried this, added the nodns /etc/conf.d/net and changing the ips in /etc/resolv.conf and ifconfig eth0 down , ifconfig eth0 up

and it worked, but when i restarted the /etc/resolv.conf file got wiped.

----------

## Stu_28

You probably have net-dns/openresolv installed. It is meant to set up /etc/resolv.conf and always runs if the /sbin/resolvconf file exists.  So, you can either try 1) unmerge the net-dns/openresolv package or 2) you could set up your DNS in /etc/conf.d/net.

For the first option, make sure that there is no resolvconf in your USE flags and then emerge -C net-dns/openresolv.  For the second option, add a line similar to dns_servers_eth0="192.168.1.1 192.168.1.2" to your /etc/conf.d/net file.

----------

## grimx

ok i did your second option and rebooted and it seems to work.

so with this option it in effect bypasses /etc/resolv.conf ??

----------

## Stu_28

No, it writes /etc/resolv.conf every time you start eth0, using those values.  You have net-dns/openresolv installed, which provides /sbin/resolvconf.  During the shutdown of eth0, if the file /sbin/resolvconf exists it gets called with the -d option--which deletes the nameserver records in /etc/resolv.conf.  So, you have to either get rid of the /sbin/resolvconf file (unmerge net-dns/openresolv) so it doesn't wipe out /etc/resolv.conf or use net-dns/openresolv (via /etc/conf.d/net or /etc/resolvconf.conf) to set up your /etc/resolv.conf...

----------

