Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 48277 - dhcpcd sets the DNS search path, overriding the DNS domain name set from /etc/dnsdomainname by /etc/init.d/domainname
Summary: dhcpcd sets the DNS search path, overriding the DNS domain name set from /etc...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-18 17:03 UTC by Simon Farnsworth
Modified: 2004-10-05 09:04 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to strip "search" from /etc/resolv.conf created by dhcpcd (domainname.patch,601 bytes, patch)
2004-09-16 18:05 UTC, Andrew Evans
Details | Diff
A patch to make the domain name set by domainname the preferred domain of the machine, overriding (but not replacing) those supplied by DHCP (Edit1,596 bytes, patch)
2004-09-29 07:27 UTC, Simon Farnsworth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Farnsworth 2004-04-18 17:03:07 UTC
I have a machine which for various reasons has to connect to a selection of networks, using DHCP to obtain its IP address on each network. I have a domain I use for it, and it has secure access to ensure that <hostname>.<my domain> is pointed at the right IP address; /etc/init.d/domainname and /etc/dnsdomainname are set up to ensure that it always has a consistent name with appropriate MX and A records.

DHCP is also used to get the address of DNS servers for the local network; some of the networks are heavily firewalled, so using a fixed DNS server is not an option, because it causes DNS to break completely. I can't let the DNS domain name vary, since I do not want to risk admin mail going to the admins of some of the networks I connect to, but dhcpcd insists on adding a "search" line to the bottom of resolv.conf, overriding my manually set domain name.

/etc/init.d/domainname is run after dhcpcd has picked up an IP address; therefore, I would expect it to override the settings from dhcpcd. However, it in fact is overriden by the DHCP settings.

The solution is to fix /etc/init.d/domainname to append "domain <my domain>" to /etc/resolv.conf, rather than have it place it at the beginning of the file. This can be achieved by changing the word "BEGIN" on line 54 to "END".

Reproducible: Always
Steps to Reproduce:
1. Set a DNS domain name in /etc/dnsdomainname
2. Use dhcpcd to obtain an IP address and DNS servers/search domain for eth0
3. Run /etc/init.d/domainname
4. Do hostname -f

Actual Results:  
I get an "Unknown host" error 

Expected Results:  
Displayed my hostname as a FQDN. 

Portage 2.0.50-r1 (default-x86-1.4, gcc-3.3.2, glibc-2.3.2-r9, 
2.6.3-gentoo-r1) 
================================================================= 
System uname: 2.6.3-gentoo-r1 i686 AMD Athlon(tm) processor 
Gentoo Base System version 1.4.3.13 
ccache version 2.3 [enabled] 
Autoconf: sys-devel/autoconf-2.58-r1 
Automake: sys-devel/automake-1.7.7 
ACCEPT_KEYWORDS="x86" 
AUTOCLEAN="yes" 
CFLAGS="-march=athlon-tbird -mcpu=athlon-tbird -Os -pipe" 
CHOST="i686-pc-linux-gnu" 
COMPILER="gcc3" 
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control" 
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" 
CXXFLAGS="-march=athlon-tbird -mcpu=athlon-tbird -Os -pipe" 
DISTDIR="/usr/portage/distfiles" 
FEATURES="autoaddcvs ccache sandbox" 
GENTOO_MIRRORS="http://gentoo.oregonstate.edu 
http://distro.ibiblio.org/pub/Linux/distributions/gentoo" 
MAKEOPTS="-j2" 
PKGDIR="/usr/portage/packages" 
PORTAGE_TMPDIR="/var/tmp" 
PORTDIR="/usr/portage" 
PORTDIR_OVERLAY="/usr/local/portage" 
SYNC="rsync://rsync.gentoo.org/gentoo-portage" 
USE="3dnow X aalib acpi alsa apm arts artswrappersuid avi berkdb cdr crypt 
cups dga dvd encode esd evms2 fam foomaticdb gd gdbm gif gnome gpm gtk gtk2 
guile ieee1394 imap imlib ipv6 java jpeg kde ldap libg++ libwww mad maildir 
mikmod mmx motif mozilla mpeg msn ncurses nls nptl oggvorbis opengl oss pam 
pdflib perl pic png postgres python qt quicktime rage128 readline samba sdl 
slang spell ssl svga tcltk tcpd tetex tiff truetype usb video_cards_rage128 
wmf x86 xml xml2 xmms xv zlib"
Comment 1 Andrew Evans 2004-09-16 18:05:35 UTC
Created attachment 39731 [details, diff]
patch to strip "search" from /etc/resolv.conf created by dhcpcd
Comment 2 Andrew Evans 2004-09-16 18:39:17 UTC
Comment on attachment 39731 [details, diff]
patch to strip "search" from /etc/resolv.conf created by dhcpcd

This fixes the problem on my network.  This will not change behavior if
/etc/dnsdomainname doesn't exist.
Comment 3 SpanKY gentoo-dev 2004-09-24 19:58:24 UTC
you can put multiple search lines in resolv.conf, you certainly dont want to go stripping all of them

if you dont want dhcpcd screwing with your resolv.conf, use the -R option
Comment 4 Simon Farnsworth 2004-09-27 02:10:11 UTC
I'm not trying to strip any lines; the domainname script *adds* a line, which is overriden by those written by DHCPCD. I want it to add the same line, but at the other end of the file, thus overriding those written by DHCPCD, so that e-mail sent by other scripts to root@<local machine name and domain> goes to the domain that domainname sets, not to one added by DHCPCD.

The idea is that *if* I set a domainname with the script, it should override those given by DHCPCD; this *leaves* the lines from DHCPCD alone.
Comment 5 Simon Farnsworth 2004-09-29 07:27:38 UTC
Created attachment 40709 [details, diff]
A patch to make the domain name set by domainname the preferred domain of the machine, overriding (but not replacing) those supplied by DHCP

Just to add; a fixed resolv.conf is not an option. At least two of the networks
I connect to have firewall rules that stop me using any DNS servers other than
the ones the DHCP server indicates.

The correct solution is not to do as Andrew Evans suggests, and strip search
(which breaks on one of the networks I use), but to change the awk script to
use "END" instead of "BEGIN"; I've attached a patch that does this.

This causes the machine to place itself in the domain supplied by
dnsdomainname, but to still search the domains supplied by DHCP
Comment 6 SpanKY gentoo-dev 2004-10-05 09:04:21 UTC
my comment was going by the patch submitted ... i missed the fact it wasnt submitted by the original bug reporter ;)

changed behavior to append the line to the file, thanks