LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Permanently set DNS after reboot (https://www.linuxquestions.org/questions/linux-newbie-8/permanently-set-dns-after-reboot-4175576811/)

Gad 04-06-2016 06:46 AM

Permanently set DNS after reboot
 
Hi LQ

I am needing to set my DNS automatically between reboots and I assume I will need to use a Bash script? On occasions I would need to edit the resolv.conf file but when I reboot it reverts back to 127.0.0.1

I am using
Code:

Linux voip-pc 3.19.0-49-generic #55~14.04.1-Ubuntu SMP Fri Jan 22 11:24:31 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Could someone please guide me to where I can find the information as to how to accomplish this?

Thank you

Emerson 04-06-2016 07:50 AM

What you mean by setting DNS automatically? resolv.conf is overwritten by DHCP client or some other network management application. You can edit it by hand, but then you have to make sure all network configuration helpers (DHCP client, etc) are either stopped or configured not to touch your resolv.conf.

jmgibson1981 04-06-2016 01:39 PM

Code:

auto br0
iface br0 inet static
        address 192.168.1.240
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers 192.168.1.1
        bridge_ports eth0
        bridge_stp on
        bridge_fd 0

add a dns nameservers line as above to your /etc/network/interfaces file.

suicidaleggroll 04-06-2016 01:52 PM

You need to set the DNS in whatever network configuration tool you use (NetworkManager, etc), because that tool will use the DNS information you tell it to overwrite /etc/resolv.conf every time you reboot. Creating a script to then overwrite /etc/resolv.conf again is an ugly hack and is best avoided.

Gad 04-07-2016 02:59 AM

Thank you for the valuable info guys. Ill fiddle a bit when I get a gap. Cheers!


All times are GMT -5. The time now is 02:28 AM.