# dhcpcd takes too long to provide DNS

## toralf

Both at my desktop and at a dedicated server I've a nagging issue with dhcpcd during boot phase.

The dhcpcd service needs too long to deliver a working DNS. Therefore the next services (apache, ntp-client, tor, mysql) either refuse to start or gives warnings.

At my desktop I circumvented it by putting this quick&dirty into /etc/init.d/apache:

```
        while [[ : ]]

        do

                host <my hostname> && break

                sleep 1

        done

```

into the start section.

But I dislike to put similar things into the init script at my server which currently immediately follows after dhcpdc, b/c that might change.

Isn't there any better solution ?

----------

## UberLord

Hi toralf

You may wish to look at this bug report:

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

Basically it allows the dhcpcd service to become re-entrant.

So you could then add the -b flag to dhcpcd to enable fast backgrounding and when an interface comes up dhcpcd will then start the depending services of your liking.

Why is it so slow though? dhcpcd configures fully working DNS very fast on all my machines. Is it a slow network?

----------

## toralf

Thx, I'll try that.

Well, whilst my desktop might be slow, the server gives me this in rc.log :

```
rc default logging started at Thu Oct  9 22:12:18 2014

...

 * Starting DHCP Client Daemon ...

 [ ok ]

 * Bringing up interface enp3s0

 *   config_enp3s0 not specified; defaulting to DHCP

 *   dhcp ...

 *     Running dhcpcd ...

dhcpcd[1752]: sending commands to master dhcpcd process

 [ ok ]

 *     received address

 [ ok ]

 * Setting clock via the NTP client 'ntpdate' ...

Exiting, name server cannot be used: Temporary failure in name resolution (-3) * Failed to set clock

 [ !! ]

 * ERROR: ntp-client failed to start

 * Starting ntpd ...

 [ ok ]

...

rc default logging stopped at Thu Oct  9 22:12:22 2014

```

== 4 seconds for this phase, I'm pretty sure it is too fast for dhcpcd to configure the resolv.conf, or ?

----------

## UberLord

Don't mix net.* services with the dhcpcd service, use one or the other please!

The dhcpcd service is of course better  :Wink: 

----------

## toralf

Ick, I'm using Gentoo for a looong time, sometimes I do miss a bigger change...

I it no longer needed to add net.wlp3so or net.enp3s0 via "rc-update add ..." to a run level ?

----------

## UberLord

No, because dhcpcd can do it for you.

You *do* have to configure dhcpcd instead of conf.d/net though.

Click the link in my .sig for a how to guide.

----------

## toralf

puh, I forgot to configure dnsmasq...

Now I do get about 1000 lines like

```
Oct 10 00:15:17 n22 dnsmasq[2400]: DBus error: Connection ":1.0" is not allowed to own the service "uk.org.thekelleys.dnsmasq" due to security policies in the configuration file

```

in my syslog before I could stop dnsmasq and configure it.

Mayby dnsmasq in level boot needs policy kit too ?Last edited by toralf on Fri Oct 10, 2014 8:45 am; edited 1 time in total

----------

## toralf

Hhm, neither dhcpcd in level boot nor using the net.* scripts solved my issue, but this did it :

```
 # cat /etc/conf.d/net

postup()

{

        if [[ "$IFACE" != "lo" ]]; then

                host $HOSTNAME

        fi

}

```

Both my desktop, my KVM machines and my dedicated server works now fine with this. OTOH my UML instances works fine with dhcpcd in level boot and no net.* script in any other level.

Update rc_depend_strict="YES" seems to work too

----------

## P.Kosunen

I have same problem and nfs-mounts are also failing. rc_depend_strict="YES" and -b flag for dhcpcd didn't help. Tried with both static and dynamic ip.

I don't have dnsmasq installed in this machine, do i really need it? Name resolution is working after i login and ntp-client and netmount init scripts are also working when run manually.

Edit: Next boot after writing above and it seems to work. Cleared some log files before boot, but that shouldn't make difference.

----------

## toralf

It helped to put this into /etc/dhcpcd.conf:

```
waitip

```

and to add the network itnerface explicitely instead of letting dhcpcd doing it during boot himself.

----------

