Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 490512 - net-misc/dhcpcd makes /etc/resolv.conf empty after a while
Summary: net-misc/dhcpcd makes /etc/resolv.conf empty after a while
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-05 22:04 UTC by Rafal Kupiec
Modified: 2013-11-08 16:36 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafal Kupiec 2013-11-05 22:04:00 UTC
Just after system bootup process the produced /etc/resolv.conf file looks good and contains information about nameserver. But if i leave the system for a while this file becomes empty and results in no possibility to resolve domain name to IP address. This occurs for few minutes and after this time, /etc/resolv.conf is again updated - this time all missing information are filled in back.


Because i use GrSecurity and i have set it up to log every command launched i could notice this:

[ 2718.115845] grsec: exec of /lib64/dhcpcd/dhcpcd-run-hooks (/lib/dhcpcd/dhcpcd-run-hooks ) by /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd:19206] uid/euid:0/0 gid/egid:0/0, parent /sbin/dhcpcd[dhcpcd:1491] uid/euid:0/0 gid/egid:0/0
[ 2718.115920] grsec: exec of /lib64/dhcpcd/dhcpcd-run-hooks (/lib/dhcpcd/dhcpcd-run-hooks ) by /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd:19207] uid/euid:0/0 gid/egid:0/0, parent /sbin/dhcpcd[dhcpcd:1357] uid/euid:0/0 gid/egid:0/0
[ 2718.135063] grsec: exec of /bin/rm (rm -f /var/run/dhcpcd/resolv.conf/enp2s0:ra ) by /bin/rm[dhcpcd-run-hook:19208] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19206] uid/euid:0/0 gid/egid:0/0
[ 2718.135533] grsec: exec of /bin/rm (rm -f /var/run/dhcpcd/resolv.conf/enp2s0:ra ) by /bin/rm[dhcpcd-run-hook:19209] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19207] uid/euid:0/0 gid/egid:0/0
[ 2718.142526] grsec: exec of /bin/sed (sed -n s/^domain //p enp2s0 enp2s0:ra ) by /bin/sed[dhcpcd-run-hook:19214] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19212] uid/euid:0/0 gid/egid:0/0
[ 2718.143395] grsec: exec of /bin/sed (sed -n s/^domain //p enp2s0 enp2s0:ra ) by /bin/sed[dhcpcd-run-hook:19215] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19213] uid/euid:0/0 gid/egid:0/0
[ 2718.147691] grsec: exec of /bin/sed (sed -n s/^search //p enp2s0 enp2s0:ra ) by /bin/sed[dhcpcd-run-hook:19218] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19216] uid/euid:0/0 gid/egid:0/0
[ 2718.148978] grsec: exec of /bin/sed (sed -n s/^search //p enp2s0 enp2s0:ra ) by /bin/sed[dhcpcd-run-hook:19219] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19217] uid/euid:0/0 gid/egid:0/0
[ 2718.153142] grsec: exec of /bin/sed (sed -n s/^nameserver //p enp2s0 enp2s0:ra ) by /bin/sed[dhcpcd-run-hook:19222] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19220] uid/euid:0/0 gid/egid:0/0
[ 2718.154727] grsec: exec of /bin/sed (sed -n s/^nameserver //p enp2s0 enp2s0:ra ) by /bin/sed[dhcpcd-run-hook:19223] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19221] uid/euid:0/0 gid/egid:0/0
[ 2718.160775] grsec: exec of /usr/bin/cmp (cmp -s /etc/resolv.conf /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /usr/bin/cmp[dhcpcd-run-hook:19226] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19206] uid/euid:0/0 gid/egid:0/0
[ 2718.161434] grsec: exec of /bin/rm (rm -f /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /bin/rm[dhcpcd-run-hook:19227] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19207] uid/euid:0/0 gid/egid:0/0
[ 2718.163470] grsec: exec of /bin/rm (rm -f /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /bin/rm[dhcpcd-run-hook:19228] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19206] uid/euid:0/0 gid/egid:0/0
[ 2718.164719] grsec: exec of /usr/bin/cmp (cmp -s /etc/resolv.conf /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /usr/bin/cmp[dhcpcd-run-hook:19229] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19207] uid/euid:0/0 gid/egid:0/0
[ 2718.166300] grsec: exec of /bin/rm (rm -f /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /bin/rm[dhcpcd-run-hook:19230] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19206] uid/euid:0/0 gid/egid:0/0
[ 2718.167339] grsec: exec of /bin/cat (cat /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /bin/cat[dhcpcd-run-hook:19231] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19207] uid/euid:0/0 gid/egid:0/0
[ 2718.169505] grsec: exec of /bin/rm (rm -f /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /bin/rm[dhcpcd-run-hook:19232] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19207] uid/euid:0/0 gid/egid:0/0
[ 2718.171685] grsec: exec of /bin/chmod (chmod 644 /etc/resolv.conf ) by /bin/chmod[dhcpcd-run-hook:19233] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19207] uid/euid:0/0 gid/egid:0/0
[ 2718.173934] grsec: exec of /bin/rm (rm -f /var/run/dhcpcd/resolv.conf.enp2s0:ra ) by /bin/rm[dhcpcd-run-hook:19235] uid/euid:0/0 gid/egid:0/0, parent /lib64/dhcpcd/dhcpcd-run-hooks[dhcpcd-run-hook:19207] uid/euid:0/0 gid/egid:0/0


I mark this as a critical, because loosing information about DNS servers (even for a short time) makes it impossible to resolve domain names to IP address and therefore impossible to connect to another services, what is unacceptable in many environments.

Reproducible: Always

Steps to Reproduce:
This happens frequently every ~1 hour. /etc/resolv.conf becomes empty for few minutes, until dhcpcd fills it in again.



[ebuild   R    ] net-misc/dhcpcd-6.1.0  USE="ipv6 udev" 0 kB
Comment 1 Thomas Deutschmann gentoo-dev 2013-11-07 08:34:49 UTC
Hi,

your logs looks fine for me. Your system receives an router advertisement, which will trigger the dhcpcd hook.

It looks like that you have two sources in the network sending RAs to your system. The first one will clear your existing configuration and after a few minutes you receive another RA from a "valid" source which will bring back your DNS configuration.

Have you verified the RA sources? Maybe you have a rogue/misconfigured client in your network...


PS: Do you really use dhcpcd to get your IPv6 addresses? If not, disable IPv6 for dhcpcd...
Comment 2 Rafal Kupiec 2013-11-07 11:12:04 UTC
There is only 1 source of RA advertisements. I have been using this configuration so far in Arch Linux w/o any problems. This problem begun to exist just after migration to Arch Hardened.

Anyway I'm going to check this once again.

I also came across another strange situation i was discussing on IRC. When i entered config_enp2s0="dhcp" into /etc/conf.d/net then the service was not starting automatically during boot process, even it was added to 'default' runlevel. What was strange, I could start this service up manually typing /etc/init.d/net.enp2s0 start. The solution was to remove those line from config file (ie. to make /etc/conf.d/net empty).
Comment 3 Rafal Kupiec 2013-11-07 11:12:35 UTC
(In reply to Rafal Kupiec from comment #2)
> There is only 1 source of RA advertisements. I have been using this
> configuration so far in Arch Linux w/o any problems. This problem begun to
> exist just after migration to Arch Hardened.
I meant Gentoo Hardened of course
Comment 4 Thomas Deutschmann gentoo-dev 2013-11-07 15:03:10 UTC
Please share the following output/content with us:

1) emerge --info

2) cat /etc/conf.d/net

3) cat /etc/conf.d/dhcpcd

4) cat /etc/dhcpcd.conf

5) rc-update

6) ps faux (want to know if multiple dhcpcd processes are running)

And please answer if you really want to use dhcpcd for configuring an IPv6 address (I am asking this to make sure you really want dhcpcd's IPv6 functionality and that you don't enabled dhcpcd's IPv6 support just because you set the general "ipv6" USE flag...).
Comment 5 Rafal Kupiec 2013-11-07 20:22:03 UTC
Yes, I'm obtaining both IPv4 & IPv6 addresses throught DHCP and looks like dhcpcd is running twice, whats actually the problem. Just i dont know why net script is starting it up twice... Some output below, I dont think more, like emerge --info will be useful to you, also there is too much confidential data to publish it here.



$ cat /etc/conf.d/net
#config_enp2s0="dhcp"

$ cat /etc/conf.d/dhcpcd
cat: /etc/conf.d/dhcpcd: No such file or directory

$ cat /etc/dhcpcd.conf 
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

$ rc-update
             bootmisc | boot                         
                devfs |                       sysinit
                dmesg |                       sysinit
                 fsck | boot                         
             hostname | boot                         
              hwclock | boot                         
              keymaps | boot                         
            killprocs |              shutdown        
                local |      default                 
           localmount | boot                         
             loopback | boot                         
              modules | boot                         
             mount-ro |              shutdown        
                 mtab | boot                         
           net.enp2s0 |      default                 
               net.lo | boot                         
             netmount |      default                 
               procfs | boot                         
                 root | boot                         
            savecache |              shutdown        
                 swap | boot                         
            swapfiles | boot                         
               sysctl | boot                         
                sysfs |                       sysinit
            syslog-ng |      default                 
         termencoding | boot                         
         tmpfiles.dev |                       sysinit
       tmpfiles.setup | boot                         
                 udev |                       sysinit
           udev-mount |                       sysinit
              urandom | boot                         

$ ps faux | grep dhcp
root      1357  0.0  0.0  15008   852 ?        Ss   Nov05   0:00 /sbin/dhcpcd -q
root     24769  0.0  0.0  11400  1036 pts/1    S+   20:14   0:00          \_ grep --color=auto dhcp
root      1491  0.0  0.0  10816   744 ?        Ss   Nov05   0:00 dhcpcd -m 2 enp2s0
Comment 6 Thomas Deutschmann gentoo-dev 2013-11-07 23:20:19 UTC
I don't need the full "emerge --info" output, but the header (first 25 lines) would be nice, so we now the important package information.

Now I have to guess that you are using openrc-0.12.x for example.
If I am right, please remove "net.lo" from boot. It is duplicated, with 0.12, the "net.lo" initscript was replaced by "loopback".

Also, your "/etc/conf.d/net" is "empty" right?
Please add

  dhcpcd="--debug"

Please also enable rc_logging, set

  rc_logger="YES"

in "/etc/rc.conf".


Now restart and check if your interface comes up and will receive an IP address.

If not, please make sure that dhcpcd is killed before you manually start your interface, to prevent multiple instances.

If you problem isn't fixed, you should now have some logs. Please attache "/var/log/rc.conf" and dhcpcd's debug log from syslog.
Comment 7 Rafal Kupiec 2013-11-08 10:01:33 UTC
Portage 2.2.7 (hardened/linux/amd64, gcc-4.8.1, glibc-2.17, 3.11.6-hardened-r3 x86_64)
=================================================================
System uname: Linux-3.11.6-hardened-r3-x86_64-Intel-R-_Atom-TM-_CPU_D510_@_1.66GHz-with-gentoo-2.2
KiB Mem:     4045620 total,   3183360 free
KiB Swap:    4095992 total,   4095992 free
Timestamp of tree: Thu, 07 Nov 2013 19:30:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-lang/python:          3.3.2-r2
dev-util/cmake:           2.8.12
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.69
sys-devel/automake:       1.13.4, 1.14
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.8.1-r1
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.11 (virtual/os-headers)
sys-libs/glibc:           2.17



Yes, my /etc/conf.d/net is empty right now.
I have made the suggested changes and i will let you know about the results.
Comment 8 Rafal Kupiec 2013-11-08 14:22:10 UTC
Actually looks like removing net.lo fixed this issue. I see only single instance of dhcpcd running now, and also nothing disturbing in logs so far.
Comment 9 Thomas Deutschmann gentoo-dev 2013-11-08 14:30:30 UTC
Thank you for your feedback.

When you think your problem was solved:
Don't forget to undo my recommended changes from comment 6, e.g. turn off logging (if you don't want to keep rc_logging) and disable dhcpcd's debug mode.

Also, feel free to close your own bug as resolved. You can always re-open or fill a new bug.
Comment 10 Rafal Kupiec 2013-11-08 16:36:08 UTC
I have already reverted all changes.
Thank you too for assists.