# [solved]network services not started when using DHCPD+OpenRC

## xaviermiller

Hi!

I use DHCPCD as main network manager with OpenRC, but I see some network service don't start automatically at boot : ntp-client (from net-misc/ntp) ("Temporary failure in name resolution") and samba ("start-stop-daemon: failed to start `/usr/sbin/smbd'", kinda a crash).

I use parallel startup (RC_PARALLEL=YES).

If I disable parallel startup (RC_PARALLEL=NO), samba starts, but still not ntp-client.

DHCPCD is started at boot runlevel, the other network services at default runlevel.

I have to start them manually.

What can I do to let them natively start?

EDIT: solution is : set dhcpcd at boot runlevel, and put "waitip" in /etc/dhcpcd.conf

----------

## Suicidal

You could try adding your network adapter to the boot runlevel to give it more time to initialize 

before network dependent services start. I know my Wireless takes about 10 seconds after login 

before I have a IP, so I just dont use ntp-client.

Once the time is set, ntpd should keep it within a few ms of the servers.

----------

## Anon-E-moose

Yeah, you need to leave some time between the network adapter being turned on/modules loaded/etc and the starting up of dhcpcd and then a little more time between that and something like ntp starting up. I know it kind of defeats the purpose of parallel, but ....

----------

## krinn

Same answer as Anon-E-moose: ntp-client is called after net, it doesn't garanty net has setup the network fine when ntp-client is called.

You may delegate the run of ntp-client and other to another initscript that do nothing except looping ping -c1 8.8.8.8 and once it have an answer trigger ntp-client and friends.

----------

## khayyam

 *krinn wrote:*   

> You may delegate the run of ntp-client and other to another initscript that do nothing except looping ping -c1 8.8.8.8 and once it have an answer trigger ntp-client and friends.

 

krinn ... all you need do is check if the network is routable: 

```
#!/bin/sh

set -e

timeout="15"

while { [ $timeout -gt 0 ] && [ -z "$(ip route show 0.0.0.0/0)" ]; } ; do

    sleep 1

    : $(( timeout -= 1 ))

done 

if [ $timeout -eq 0 ] ; then

    echo "do something here"

else

    /etc/init.d/ntp-client start

fi
```

... or something like that.

best ... khay

----------

## Anon-E-moose

once "ip route show default" gives you a valid ip then you're good to go with net-client, samba, etc.

I would imagine a one second delay after dhcpd would be plenty of time or move their startup to /etc/local.d/baselayout1.start

I have a usb drive that (most of the time) was starting normally, but once in a while it would't start up, so I turned of auto mount for it and added the mount command to /etc/local.d

----------

## bunder

are you using /etc/init.d/dhcpcd or /etc/init.d/net.* ?  if you're using the dhcpcd init script, i'd try net.* instead with a /etc/conf.d/net containing 

```
config_eth0="dhcpcd"
```

----------

## P.Kosunen

Put "waitip" option to dhcpcd.conf and it waits until it gets ip before starting other services depending network.

----------

## Suicidal

There’s also the timeout value in ntpdate, but if you’re willing to do that; there’s no sanity in setting RC_PARALLEL.

```
-t timeout

Specify the maximum time waiting for a server response as the. value timeout, in seconds and fraction.  The value is rounded to a multiple of 0.2 seconds. The default is 1 second, a valuesuitable for polling across a LAN.
```

----------

## xaviermiller

Hi,

Thank you all for your replies !

 *bunder wrote:*   

> are you using /etc/init.d/dhcpcd or /etc/init.d/net.* ?  if you're using the dhcpcd init script, i'd try net.* instead with a /etc/conf.d/net containing 
> 
> ```
> config_eth0="dhcpcd"
> ```
> ...

 

Yes, I was using dhcpcd and not net.* scripts

 *P.Kosunen wrote:*   

> Put "waitip" option to dhcpcd.conf and it waits until it gets ip before starting other services depending network.

 

This fix works for me ! + setting dhcpcd at boot level, and the network related services in the default runlevel

Thanks  :Cool: 

----------

