Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-06-2016, 06:46 AM   #1
Registered: May 2013
Location: Republic of South Africa
Distribution: Debian 8.0 "jessie"
Posts: 189

Rep: Reputation: 7
Cool Permanently set DNS after reboot


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

I am using
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

Last edited by mariose; 04-06-2016 at 06:47 AM. Reason: Adding my distro to the fault
Old 04-06-2016, 07:50 AM   #2
LQ Guru
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,959

Rep: Reputation: Disabled
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.
Old 04-06-2016, 01:39 PM   #3
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Ubuntu LTS
Posts: 136

Rep: Reputation: Disabled
auto br0
iface br0 inet static
        bridge_ports eth0
        bridge_stp on
        bridge_fd 0
add a dns nameservers line as above to your /etc/network/interfaces file.
Old 04-06-2016, 01:52 PM   #4
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,410

Rep: Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019Reputation: 2019
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.
Old 04-07-2016, 02:59 AM   #5
Registered: May 2013
Location: Republic of South Africa
Distribution: Debian 8.0 "jessie"
Posts: 189

Original Poster
Rep: Reputation: 7
Thank you for the valuable info guys. Ill fiddle a bit when I get a gap. Cheers!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to permanently change hostname even after reboot BW-userx Slackware 5 07-12-2015 09:43 AM
Set permissions permanently massy Linux - Security 2 03-09-2014 04:42 AM
How to permanently set shmmax tikit Linux - Server 3 06-11-2010 01:39 AM
Sceernlock switches off monitor permanently thereby forcing me to reboot the machine harry2006 Linux - Desktop 4 10-10-2008 03:49 AM
How to set PATH permanently chandhru Linux - Newbie 3 09-24-2002 12:43 AM

All times are GMT -5. The time now is 02:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration