You are not logged in.

#1 2008-03-13 10:26:15

Paingiver
Member
Registered: 2008-03-01
Posts: 83

Prevent Network Manager from changing my DNS-And good books aboutLinux

-R option here is not working. What should i do?

Also i want to learn more about the Linux. The wiki's are good to make one thing,but they are not getting to details much. I want something deeper. I want every detail,mentioning even the smallest thing. So what can you suggest?

And i've always wondered why Windows booting faster than GNU/Linux systems?In 20-25 seconds the desktop gets 
ready.

Last edited by Paingiver (2008-03-13 10:57:15)

Offline

#2 2008-03-13 10:39:11

Jarsto
Member
From: Groningen, The Netherlands
Registered: 2005-11-18
Posts: 35
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

One quick and dirty way to work around DHCP resetting your DNS is to just reset your resolv.conf using /etc/rc.local

#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#
# set first nameserver
echo "nameserver 0.0.0.0" > /etc/resolv.conf
# set second nameserver
echo "nameserver 0.0.0.0" >> /etc/resolv.conf

Obviously replace the 0.0.0.0 with the appropriate IP addresses for your nameservers.

No book suggestions I'm afraid. But I'm pretty sure about how Windows appears to boot so fast: it cheats. Windows essentially throws you onto the desktop before it's finished loading everything. That's why it's always slow starting any application clicked the first 30 seconds or so after it's "finished" booting.

Edit: fixed a spelling error

Last edited by Jarsto (2008-03-13 10:40:28)


Jarsto

Offline

#3 2008-03-13 10:47:54

mianka
Member
From: BE LEUVEN
Registered: 2006-05-30
Posts: 230

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Have alook at O"Reilly books,they sometimes even have free PDF"s.

Offline

#4 2008-03-13 11:15:23

Paingiver
Member
Registered: 2008-03-01
Posts: 83

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Thanks for the quick replies!

echo "nameserver 0.0.0.0" > /etc/resolv.conf
# set second nameserver
echo "nameserver 0.0.0.0" >> /etc/resolv.conf

So, Jarsto it will be ">" or ">>" ? Or the way you right is correct?

Last edited by Paingiver (2008-03-13 11:30:04)

Offline

#5 2008-03-13 12:19:55

Jarsto
Member
From: Groningen, The Netherlands
Registered: 2005-11-18
Posts: 35
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Paingiver wrote:

Thanks for the quick replies!

echo "nameserver 0.0.0.0" > /etc/resolv.conf
# set second nameserver
echo "nameserver 0.0.0.0" >> /etc/resolv.conf

So, Jarsto it will be ">" or ">>" ? Or the way you right is correct?

You use > for the first one, because > makes it overwrite what's in the file before then (the automatic stuff). Then you use >> to add more lines to the bottom if you want to list several nameservers.


Jarsto

Offline

#6 2008-03-13 23:05:11

Paingiver
Member
Registered: 2008-03-01
Posts: 83

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Unfortunately it doesn't work for me. Do you have another solution?

Offline

#7 2008-03-14 09:38:02

Jarsto
Member
From: Groningen, The Netherlands
Registered: 2005-11-18
Posts: 35
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Paingiver wrote:

Unfortunately it doesn't work for me. Do you have another solution?

That depends on how it doesn't work.

If you restart the computer, or simply run /etc/rc.local as root, what's in your /etc/resolv.conf afterwards?


Jarsto

Offline

#8 2008-03-14 17:35:26

Paingiver
Member
Registered: 2008-03-01
Posts: 83

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

I am on the edge. I've been working on this wireless to get work for 1 week. And i am getting frustrated. I have Ralink with rt2500 chipset. For now i am trying the netcfg2. Though the result is same in network-manager.I can connect to wireless network but after 30 seconds i cannot browse any site.It is still seen as connected though.

My rc.conf:

eth0="dhcp"
wlan0="dhcp"
INTERFACES=(lo eth0 wlan0)
#
# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
#gateway="default gw 192.168.0.1"
ROUTES=(!gateway)
#
# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network-profiles
#
#NET_PROFILES=()

#
# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng !netfs crond alsa hal fam network)

My iwconfig:

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11g  ESSID:""  
          Mode:Managed  Frequency:2.412 GHz  Access Point: Not-Associated   
          Tx-Power=27 dBm   
          Retry min limit:7   RTS thr:off   Fragment thr=2346 B   
          Encryption key:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

iwlist scan works. And whenever i boot or restart the network i get this:

err, wlan0: timed out
err, wlan0: lease expired 20153 seconds ago
warn, wlan0: using IPV4LL address 169.254.51.42

Offline

#9 2008-03-14 17:43:16

Paingiver
Member
Registered: 2008-03-01
Posts: 83

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Jarsto wrote:
Paingiver wrote:

Unfortunately it doesn't work for me. Do you have another solution?

That depends on how it doesn't work.

If you restart the computer, or simply run /etc/rc.local as root, what's in your /etc/resolv.conf afterwards?

There's no problem when i connect with cable.But when i connect with wireless,here is the result of resolve.conf:

# Generated by dhcpcd for interface wlan0
nameserver 192.168.1.1

Offline

#10 2008-03-15 08:30:08

Jarsto
Member
From: Groningen, The Netherlands
Registered: 2005-11-18
Posts: 35
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Paingiver wrote:

iwlist scan works. And whenever i boot or restart the network i get this:

err, wlan0: timed out
err, wlan0: lease expired 20153 seconds ago
warn, wlan0: using IPV4LL address 169.254.51.42

This definitely looks like a problem with the wireless. A 169.254.*.* IP is usually an IP address a computer takes when it isn't given one through DHCP.  Unfortunately I don't know a lot about wireless setup, but maybe someone else will know what the problem could be.

Paingiver wrote:

There's no problem when i connect with cable.But when i connect with wireless,here is the result of resolve.conf:

# Generated by dhcpcd for interface wlan0
nameserver 192.168.1.1

This seems to indicate the wireless DHCP is the last thing that touches /etc/resolv.conf. One way around that is to add a sleep command to /etc/rc.local to make it wait until DHCP for wireless has finished running. Just add "sleep 30" before the resolv.conf update to make it wait 30 seconds.

Unfornately the wireless problem above means that while waiting may correct resolv.conf, the connection probably won't work. Also chances are that without the errors things won't take as long, so you won't need to make rc.local wait, or at least won't need to make it wait as long (another option to help with this is put network earlier in your /etc/rc.local daemons array, right now it's the last thing running before rc.local).


Jarsto

Offline

#11 2008-08-29 14:32:38

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

I have the same problem. Adding those lines to rc.local and rebooting, doesn't prevent Networkmanager from editing /etc/resolv.conf at the end. Is there any other suggestion?


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#12 2008-08-29 14:45:11

gav616
Member
Registered: 2008-01-16
Posts: 182

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Offline

#13 2008-08-29 18:11:10

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

No, that only applies to dhcpcd, Networkmanager doesn't rely on that, apparently.
I have found a solution on some forum though. Put a script like this in /etc/Networkmanager/dispatcher.d/ and don't forget to make it executable:

#!/bin/bash
#
# Override /etc/resolv.conf and tell
# NetworkManagerDispatcher to go pluck itself.
#
# scripts in the /etc/NetworkManager/dispatcher.d/ directory
# are called alphabetically and are passed two parameters:
# $1 is the interface name, and $2 is "up" or "down" as the
# case may be.

# Here, no matter what interface or state, override the
# created resolver config with my config.

cp -f /etc/resolv.conf.myDNSoverride /etc/resolv.conf

Then create a file with the nameservers (in my case opendns ones), according to what you specified on the script (in my case /etc/resolv.conf.myDNSoverride):

nameserver 208.67.222.222
nameserver 208.67.220.220

Of course you'll have to start the daemon networkmanager-dispatcher. big_smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#14 2009-01-24 14:40:34

thunderogg
Member
From: Rio de Janeiro
Registered: 2008-07-13
Posts: 172

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

Thanks a lot for that solution. It works great!!! Why not put it in the wiki?

Offline

#15 2009-01-24 16:30:02

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

thunderogg wrote:

Thanks a lot for that solution. It works great!!! Why not put it in the wiki?

go ahead, put it on the wiki


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#16 2009-01-24 16:53:58

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

I think changing the /etc/resolv.conf permission to read only may also help.

Offline

#17 2009-12-01 06:17:58

clvn
Member
From: Norway
Registered: 2008-08-31
Posts: 20
Website

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

(First of all, sorry for bumping an old thread. The problem persist for me, so its still a problem for some people out there.)

@kgas: changing the permission to 444 (sudo chmod 444 /etc/resolv.conf) did not prevent the file from being overwritten.

Offline

#18 2009-12-02 16:14:22

tinhtruong
Member
From: Australia
Registered: 2008-12-18
Posts: 117

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

What I do in Network Manager is to edit my connection, under 'IPv4 Settings' tab I chose the method 'Automatic (DHCP) addresses only' and manually specify my preferred DNS servers (separated by comma). Network Manager will always override my /etc/resolv.conf, but with the same DNS servers. And I find this method is simpler than the above.
It's just personal preference though. smile

Offline

#19 2009-12-02 16:32:31

hokasch
Member
Registered: 2007-09-23
Posts: 1,461

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

changing the permission to 444 (sudo chmod 444 /etc/resolv.conf) did not prevent the file from being overwritten

chattr +i /etc/resolv.conf does prevent it from being changed, but it may not be a particular subtile way to do this.

edit: whoo, this thread was well aged indeed.

Last edited by hokasch (2009-12-02 16:34:36)

Offline

#20 2009-12-03 18:06:04

Mad Fish
Member
Registered: 2009-09-22
Posts: 295

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

tinhtruong, thanks! That's much better than such hacks.

I accidentally didn't noticed that option.

Offline

#21 2013-08-08 14:15:55

nrq
Member
From: MX
Registered: 2013-08-08
Posts: 3

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

If not using any GUI method, then you need to edit the file which contains the properties about the connection.

To get a list of the saved connections:

$ ls -l /etc/NetworkManager/system-connections/

Edit the desired file, find the ipv4 section you might find something like:

[ipv4]
method=auto

Make it look like this (If you want to use OpenDNS):

[ipv4]
method=auto
dns=208.67.222.222;208.67.220.220;
ignore-auto-dns=true

I also turned off ipv6 by now.

[ipv6]
method=ignore

Offline

#22 2013-08-08 14:33:17

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,209

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

nrq,
First of, Welcome to Arch Linux smile

Be aware, this thread is a bit long-in-the-tooth.  I have not seen a couple of these members in years sad
Generally we discourage reviving old posts, as thing in Linux change so fast.  As far as I can tell, your posts are still relevant, so I am going to not close this thread; just to expect a response to a three and a half year old thread.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#23 2013-12-27 19:35:46

tankas
Member
From: Dublin
Registered: 2013-12-27
Posts: 11

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

If you use DHCP and you do not want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of /etc/dhcpcd.conf:

nohook resolv.conf

Taken from:
https://wiki.archlinux.org/index.php/Dh … CP_at_boot


Everyday iBiker

Offline

#24 2014-04-05 10:08:42

limyreth
Member
Registered: 2010-01-09
Posts: 18

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

tankas wrote:

If you use DHCP and you do not want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of /etc/dhcpcd.conf:

nohook resolv.conf

...

Network manager takes output from dhclient or dhcpcd and then writes that to /etc/resolv.conf. That nohook only prevents dhcpcd from writing to /etc/resolv.conf.

This worked for me: append to /etc/dhcpcd.conf:

nohook resolv.conf
static domain_search=your.domain.example.org
static domain_name_servers=8.8.8.8 4.4.4.4

Edit: added this to wiki

Last edited by limyreth (2014-04-05 10:21:26)

Offline

#25 2014-04-07 21:11:58

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Prevent Network Manager from changing my DNS-And good books aboutLinux

This thread has run its course...

Closing...


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

Board footer

Powered by FluxBB