Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SOLVED: problems with resolv.conf
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
mjcoss
n00b
n00b


Joined: 13 Aug 2010
Posts: 12

PostPosted: Fri Oct 25, 2013 8:54 pm    Post subject: SOLVED: problems with resolv.conf Reply with quote

I'm adding a couple of virtual bridges to my machine - br1 and br2. So I added a few lines to /etc/conf.d/net, like so

bridge_br1="fakeif1"
config_br1="192.168.1.1/24"
brctl_br1="setfd 0
sethello 1
stp off"

and a similar setup for br2, and link appropriate /etc/init.d/net.br? to /etc/init.d/net.lo and try starting them using

% /etc/init.d/net.br1 start

Doing this cause /etc/resolv.conf to be overwritten with effectively an empty file. I am running dhcp on my real network, and need to have it be the only interface that updates resolv.conf. But I can't seem to get whatever module is overwriting resolv.conf to quit it. At first I thought it might be some ipv6 weirdness, but I disabled it to no avail. I even tried adding a --allowinterfaces option to my dhcpcd line. Is there some magic keyword I can put into /etc/conf.d/net to say leave resolv.conf alone for the given interface.

Thanks.


Last edited by mjcoss on Fri Nov 01, 2013 7:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2109
Location: Near Toronto

PostPosted: Fri Oct 25, 2013 9:43 pm    Post subject: Reply with quote

perhaps

Code:
dhcp_eth0="nodns"


(for whatever interface ...)
_________________
.... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme)
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5236
Location: France, Old Europe

PostPosted: Sun Oct 27, 2013 10:10 am    Post subject: Reply with quote

Code:
dhcpcd_eth0=" -C resolv.conf"

_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.

AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 9057

PostPosted: Sun Oct 27, 2013 4:02 pm    Post subject: Reply with quote

Both should work, but the solution proposed by albright has the advantage that it should do the right thing without regard to which DHCP client you use. The solution proposed by Gentree is explicitly applicable only when using dhcpcd.
Back to top
View user's profile Send private message
mjcoss
n00b
n00b


Joined: 13 Aug 2010
Posts: 12

PostPosted: Mon Oct 28, 2013 4:04 pm    Post subject: Reply with quote

The problem is that I'm trying to set up 3 bridges - 1 that is really connected and 2 that are for testing.

The real one needs to use dhcp to get a real address
config_br0="dhcp"
config_enp13s0="null"
config_enp12s0="null"
dhcpcd_br0="-t 10"
brctl_br0="setfd 0
sethello 1
stp on"

depend_br0(){
need net.enp13s0
}

And this works fine when I bring up br0, it correctly gets an IP address, updates resolv.conf and all is good. The other bridges are for testing purposes only, and have static ip addresses associated with them, thus

bridge_br1="fakebridge"
config_br1="192.168.1.1/24"
brctl_br1="setfd 0
sethello 1
stp off"

but if I start br1 via the init.d/net.br1, it overwrites resolv.conf with a null file. Note there is no dhcp specified in br1 configuration (static ip), and no reason for resolv.conf to be overwritten. I could add a dhcp_br1="nodns" or the alternative -C resolv.conf since I am using dhcpcd but that seems wrong.
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5236
Location: France, Old Europe

PostPosted: Tue Oct 29, 2013 6:11 am    Post subject: Reply with quote

man dhcpcd:
Quote:

SYNOPSIS
dhcpcd [-ABbDdEGgHJKkLnpqTVw] [-C, --nohook hook] [-c, --script script] [-e, --env value]
[-F, --fqdn FQDN] [-f, --config file] [-h, --hostname hostname] [-I, --clientid clientid]
[-i, --vendorclassid vendorclassid] [-l, --leasetime seconds] [-m, --metric metric]
[-O, --nooption option] [-o, --option option] [-Q, --require option] [-r, --request address]
[-S, --static value] [-s, --inform address[/cidr]] [-t, --timeout seconds] [-u, --userclass class]
[-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-y, --reboot seconds]
[-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern] [-z, --allowinterfaces pattern]
[interface] [...]


from /var/log/messages I see:
Code:

Oct 29 07:55:40 localhost init: Entering runlevel: 3
Oct 29 07:55:41 localhost dhcpcd[1763]: version 5.5.6 starting
Oct 29 07:55:41 localhost dhcpcd[1763]: all: not configured to accept IPv6 RAs



So it looks like dhcpcd is started with "all" interfaces. You could find out where to change that or conclude it will scan all interfaces and thus putting in the specific options is not "wrong".

That's the way I read it, I do not claim much expertise in this area.
8)
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.

AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86
Back to top
View user's profile Send private message
mjcoss
n00b
n00b


Joined: 13 Aug 2010
Posts: 12

PostPosted: Tue Oct 29, 2013 5:31 pm    Post subject: Reply with quote

Nope. Adding those lines, either dhcp_br1="nodns" or dhcpcd_br1="-C resolv.conf" have absolutely no effect. And I do not see any reference to "all interfaces" in my /var/log/message with regards to dhcpcd. And as I mentioned I tried adding to dhcpcd_br0="-z br0" to say that I only want it on br0. That doesn't work either. Note that it is not dhcpcd that is overwriting my resolv.conf but rather something labelled "net-scripts"

The first line in resolv.conf after I start the bridge br1
# Generated by net-scripts for interface br1

The first line in resolv.conf after I start the bridge br0
# Generated by dhcpcd from br0

The first appears to come from /lib/netifrc/net/system.sh but I can't seem to find a way to get it either not run the script or just leave resolv.conf alone.
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5236
Location: France, Old Europe

PostPosted: Tue Oct 29, 2013 6:58 pm    Post subject: Reply with quote

Quote:
# Generated by dhcpcd from br0


Then you need to make your dhcpcd options relate to br0 not br1.

re albright's suggestion
Code:
dhcp_br1="nodns"
in /etc/conf.d/net

you will need to do it for all interfaces , since it only has to happen once (unless you are sure which it is an minimise later).

Also (or rather alternatively) in /etc/dhcpcd.conf

Code:
nohook resolv.conf


That should fix one culprit.

Rather than saying what you don't see post what you do see re. dhcp in /var/log/messages
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.

AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5236
Location: France, Old Europe

PostPosted: Tue Oct 29, 2013 7:33 pm    Post subject: Reply with quote

Quote:
Note that it is not dhcpcd that is overwriting my resolv.conf but rather something labelled "net-scripts"


Then find out what package that comes from and check the doc / man page.
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.

AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86
Back to top
View user's profile Send private message
mjcoss
n00b
n00b


Joined: 13 Aug 2010
Posts: 12

PostPosted: Tue Oct 29, 2013 7:37 pm    Post subject: Reply with quote

Obviously, I'm not being clear. I have 3 bridges.

One is connected to my corp network and I need dhcp to get an address, set the routes, and give me a resolv.conf for dns. This is br0. The other two bridges, br1 and br2, are test bridges which do not use dhcp, have statically provisioned ip address, and I want to be able to start them by default at system startup via /etc/init.d/net.br1 and /etc/init.d/net.br2

These are the messages in /var/log/message re: dhcpcd
Oct 7 11:58:11 cerberus dhcpcd[4035]: br0: carrier acquired
Oct 7 11:58:11 cerberus dhcpcd[4035]: br0: soliciting an IPv6 router
Oct 7 11:58:11 cerberus dhcpcd[4035]: br0: rebinding lease of xxx.xxx.xxx.xxx
Oct 7 11:58:21 cerberus dhcpcd[4035]: br0: leased xxx.xxx.xxx.xxx for 259200 seconds
Oct 7 11:58:21 cerberus dhcpcd[4035]: br0: adding host route to xxx.xxx.xxx.xxx via 127.0.0.1
Oct 7 11:58:21 cerberus dhcpcd[4035]: br0: adding route to xxx.xxx.xxx.0/23
Oct 7 11:58:21 cerberus dhcpcd[4035]: br0: adding default route via xxx.xxx.xxx.xxx
Oct 7 11:58:21 cerberus dhcpcd[4035]: forked to background, child pid 4087

which is what I expect and need. Starting br1 and/or br2 do not generate any dhcpcd messages but does overwrite resolv.conf. And as I've shown, resolv.conf is not be rewritten by dhcpcd but by net-scripts. Restarting br0 will restore resolv.conf so I guess I could just add a dependency that says that br0 must start after br1 and br2 which will give me the right resolv.conf, but I had hoped for a better way to stop the scripts from regenerating resolv.conf incorrectly.
Back to top
View user's profile Send private message
Gentree
Watchman
Watchman


Joined: 01 Jul 2003
Posts: 5236
Location: France, Old Europe

PostPosted: Tue Oct 29, 2013 8:14 pm    Post subject: Reply with quote

OK, so you could work around it but you want to understand and control it rather than walk away. I'd probably be the same.

So repeat my last suggestion:

Then find out what package that [init-scripts] comes from and check the doc / man page.
_________________
Linux, because I'd rather own a free OS than steal one that's not worth paying for.

AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86
Back to top
View user's profile Send private message
mjcoss
n00b
n00b


Joined: 13 Aug 2010
Posts: 12

PostPosted: Tue Oct 29, 2013 9:34 pm    Post subject: Reply with quote

Well it's part of the net-misc/netifrc package and no man pages. There are 2 docs in /usr/share but nothing particularly enlightening jumps out at me in those two files as a way to stop resolv.conf from being overwritten by system.sh. But looking at the script it does seem that if "/sbin/resolvconf" is installed, it will pass the updates to it rather than overwriting the file. Might be a better hack than pinning the order of startup of the bridges.
Back to top
View user's profile Send private message
TomWij
Developer
Developer


Joined: 04 Jul 2012
Posts: 1551

PostPosted: Tue Oct 29, 2013 9:56 pm    Post subject: Reply with quote

mjcoss wrote:
Well it's part of the net-misc/netifrc package and no man pages. There are 2 docs in /usr/share but nothing particularly enlightening jumps out at me in those two files as a way to stop resolv.conf from being overwritten by system.sh. But looking at the script it does seem that if "/sbin/resolvconf" is installed, it will pass the updates to it rather than overwriting the file. Might be a better hack than pinning the order of startup of the bridges.


Documentation is present at:

/usr/share/doc/netifrc-0.1/README.bz2
/usr/share/doc/netifrc-0.1/net.example.bz2

Bug about less accessible documentation filed at:

https://bugs.gentoo.org/show_bug.cgi?id=489822

Bug about an accessible solution for resolf.conf being overwritten filed at:

https://bugs.gentoo.org/show_bug.cgi?id=489826

I don't have any experience with bridges; but if you keep experiencing this, feel free to ping me and I can ask the netifrc developers to take a look.
Back to top
View user's profile Send private message
mjcoss
n00b
n00b


Joined: 13 Aug 2010
Posts: 12

PostPosted: Fri Nov 01, 2013 7:38 pm    Post subject: Reply with quote

So it turns out that if you emerge openresolv, this installs /sbin/resolvconf. And /sbin/resolvconf correctly maintains /etc/resolv.conf no matter what order I bring up the bridges by default. I didn't have to make any system configuration changes. Without it, I could find no obvious solution to the bad behaviour of the netifc scripts.

Thanks for the suggestions.
Back to top
View user's profile Send private message
ulenrich
Veteran
Veteran


Joined: 10 Oct 2010
Posts: 1160

PostPosted: Fri Nov 01, 2013 7:55 pm    Post subject: Reply with quote

dhcpd
is meant as a super-meta daemon
(which eg. by default also manages wpa_supplicant when additional git patch applied).

So, why not try the other way round:

1) let /sbin/resolvconf just handle
a) /etc/resolv.conf.head
b) /etc/resolv.conf.tail
as apropriate for your purposes.

2) let dhcpd create /etc/resolv.conf out of the above
... just an idea ...

[edit] Uups, this thread just turned solved meanwhile
_________________
fun2gen2
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum