Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Configuring manual DNS search domains
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
sirnickity
n00b
n00b


Joined: 23 Aug 2005
Posts: 17

PostPosted: Thu Nov 21, 2013 9:54 pm    Post subject: Configuring manual DNS search domains Reply with quote

Having some trouble configuring Gentoo networking to stop clobbering my /etc/resolv.conf. This is a workstation configuration that needs to use DHCP for IP lease and gateway. Nameservers can be either pulled dynamically or defined, I don't care which. However, I need to specify search domains.

My understanding of resolv.conf (from the man page) is that search and domain are mutually-exclusive options, so having DHCP set the domain line is a problem.

Relevant packages are:
- gentoo-sources 3.10.17
- baselayout 2.2
- udev 204, udev-init-scripts 26
- dhcpcd 5.6.4

Ethernet interface ends up named enp63s0 -- a surprise to me, but it's been about a year since I've done a new build, and that's an enternity in Linux-years. I assume this is the new normal.

Here's my /etc/conf.d/net file:

Code:
config_enp63s0="dhcp"
dhcp="nodns nontp nonis nosendhost"
dhcpcd="-t 5 -C resolv.conf"
dns_search="domainA.com domainB.com"
dns_servers="1.2.3.4 5.6.7.8"


I've tried with and without "_enp63s0" at the end of the dhcp/dns options. Either way, after doing this:

Code:
cat /dev/null > /etc/resolv.conf
/etc/init.d/net.enp63s0 restart


...I end up getting a resolv.conf that looks like this:

Code:
# Generated by dhcpcd from enp63s0
# /etc/resolv.conf.head can replace this line
domain domainB.com
nameserver 1.1.1.1
nameserver 1.1.1.2
# /etc/resolv.conf.tail can replace this line


The nameservers are pulled from DHCP (which is OK, they're the same ones I would use, but I've intentionally chosen different ones in /etc/conf.d/net to see which option wins), and so is the domain name. Search domains are nowhere to be found.

I've read the various scattered sections of the (IMO, rather poorly organized) net.example file and don't know what I'm missing here. Help! :!:
Back to top
View user's profile Send private message
massimo
Veteran
Veteran


Joined: 22 Jun 2003
Posts: 1226

PostPosted: Fri Nov 22, 2013 6:58 am    Post subject: Reply with quote

You could put the search domains in /etc/resolv.conf.head.
_________________
Hello 911? How are you?
Back to top
View user's profile Send private message
sirnickity
n00b
n00b


Joined: 23 Aug 2005
Posts: 17

PostPosted: Fri Nov 22, 2013 8:17 pm    Post subject: Reply with quote

Well, technically it would have to be resolv.conf.tail, because:

Quote:
The domain and search keywords are mutually exclusive. If more than one instance of these keywords is present, the last instance wins.

(man resolv.conf)

Anyway, that should work (as would write-protecting the file) but since the net configuration file apparently has the options necessary to deal with these things, I'd like to learn how to do it "the right way" rather than resort to hacks. Although maybe it's just broken and I have no other choice. :wink:
Back to top
View user's profile Send private message
albright
Advocate
Advocate


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

PostPosted: Fri Nov 22, 2013 8:42 pm    Post subject: Reply with quote

I'm curious if specifying the interface helps with the nodns
setting, that is

dhcp_enp63s0="nodns"

(By the way, you can get rid of the ludicrous new interface names
pretty easily; just touch /etc/udev/80-net-name-slot.rules)
_________________
.... 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
sirnickity
n00b
n00b


Joined: 23 Aug 2005
Posts: 17

PostPosted: Sat Nov 23, 2013 12:17 am    Post subject: Reply with quote

Hey! After changing udev rules and adding _eth0 to the dhcp options, it works! :D

For those playing along, it looks like the "rules.d" part is missing in the udev path above. It should be "/etc/udev/rules.d/80-net-name-slot.rules". (Thanks for the tip on that, BTW!)
Back to top
View user's profile Send private message
sirnickity
n00b
n00b


Joined: 23 Aug 2005
Posts: 17

PostPosted: Wed Jan 15, 2014 3:55 am    Post subject: Reply with quote

Alright, not sure what happened, but after swapping for a new PC (same hard drive), the problem came back. I verified the interface name is still (or again) net.eth0.

Configs:

/etc/conf.d/net
Code:
config_eth0="dhcp"
dhcp_eth0="nodns nontp nonis nosendhost"
dhcpcd_eth0="-t 10 -C resolv.conf"
dns_search="domainA.net  domainB.net"
dns_servers="1.2.3.4  5.6.7.8"


/etc/resolv.conf (this is what got created after restarting net.eth0, minus the head/tail comments)
Code:
domain domainB.net
nameserver 1.2.3.4
nameserver 5.6.7.8


After looking around in man dhcpcd, I found the "-S" option, and applied this line to /etc/conf.d/net:

Code:
dhcpcd_eth0="-t 10 -S domain_search=attalascom.net\ mgmt.attalascom.net"


Restarted net.eth0 and it appears to be working! :)

On a related note, the dhcpcd man page options section cites an example of "-C resolv.conf" to skip the hook script. In the "Hooking into DHCP events" section, it refers to this script as "20-resolv.conf". The latter appears correct, as this file exists in /lib64/dhcpcd/dhcpcd-hooks while the file "resolv.conf" does not.

Hoping this helps someone arriving via search.
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