I frequently switch network connections on my laptop. When I run dhcpcd, I want the dns servers in /etc/resolv.conf to be updated, but I do not want my list of search domains to be overwritten with just the domain the local DHCP server supplies. I can find no way to configure dhcpcd or scripts that call it to write domain search entries back to resolv.conf other than to edit them by hand. If there is no way to configure the system to do this, there should be.
if you're using baselayout-1.9.x, read `man dhcpcd` if you're using baselayout-1.11.x, read /etc/conf.d/net.example
I'm using baselayout-1.9. The only thing in man dhcpcd(8) that I find relevant is the -R option. This is _not what I am asking for_. The -R option prevents dhcpcd from updating either the search domains or the DNS servers. I want granularity in this - I want to update my DNS servers (so that they're local to my network) but not my search domains (so that all of my home domains are still searched). If I'm missing some other option, please let me know.
there is no configure option for that level of granularity
Created attachment 59891 [details, diff] dhcpcd patch to cache and restore search domains when updating resolv.conf Proposed patch to dhcpcd. This is very preliminary. I couldn't find a good unused letter for the option so I chose 'Z'. Also I'm not sure if the save block is in the correct location in dhcpconfig.c. This is my first bugzilla patch ever, so let me know if anything is horribly wrong.
'e' is probably the best unused dhcpcd option letter for this (k, s, r are taken)
Your patch is rejected, but functionality will be provided to achieve what you require. baselayout-1.12.0-alpha3 will allow the dns_search_domains_{eth0|essid|mac|apmac}="foo bar" variable in /etc/conf.d/net to work in conjuction with dhcpcd-1.3.22_p4-r10 - neither of which are in portage at this time. I'll close this bug as FIXED when both are available in portage.
might want to check /etc/conf.d/domainname and make sure you're not duplicating functionality with the OVERRIDE variable
/etc/conf.d/domainname just sets the dns and nis domain names. We're talking about search domains. For example in /etc/resolv.conf domain foo nameserver 192.168.0.1 search bar spanky This sets the hosts dns domain to foo and if any non FQDN requests cannot be matched in the foo domain then it will search bar and then spanky domains. Current dhcpcd in portage doesn't set the domain - instead it sets the search domains. This is bad behaviour really. I currently have a dhcpcd patch which I'm testing that sets up decent /etc/{resolv,ntp,yp}.conf files based on what dhclient and udhcpc currently do. So I don't think I'm reproducing any functionality here.
Fixed in baselayout-1.12.0_pre1-r1