# Samba crashes on startup [solved]

## Tom_

Hi,

I have got a problem for a while with Samba on my Gentoo workstation. Sometimes Samba doesn't start and appears to have crashed according to the init script.

thomas@gentoo ~ % sudo /etc/init.d/samba status

Mot de passe : 

 * status: crashed

When Samba crashes on startup, I have the following error in Samba log : 

[2012/05/21 18:07:35,  3] ../lib/util/util_net.c:70(interpret_string_addr_internal)

  interpret_string_addr_internal: getaddrinfo failed for name 0.0.0.0 [Address family for hostname not supported]

[2012/05/21 18:07:35,  0] nmbd/nmbd.c:689(open_sockets)

As the Samba init script is run after the net script, I guess that this issue happens only when it takes too long to get an IP address (DHCP).

I would like to stick with dhcp but I wonder if I can configure Samba to start only when I have  proper IP address ? 

ThanksLast edited by Tom_ on Fri Jan 31, 2014 2:12 pm; edited 1 time in total

----------

## honp

Try it with static ip and hostname, than with dhcp.

----------

## popsUlfr

Yeah that issue was pretty annoying. What I did was creating a hacky script

```

#!/bin/sh

sleep 10 && /etc/init.d/samba start &

```

which I called 'sambadelayed.start' and dropped in my '/etc/local.d' directory (and chmod +x of course).

Finally I removed samba from the default runlevel. No issues so far  :Smile: 

If you're using NetworkManager you may look into creating a dispatcher script (much cleaner!)

```

#!/bin/sh

INTERFACE=${1} # the interface that's brought up or down

STATUS=${2} # state 'up' or 'down'

case "${STATUS}" in

   'up') # the case where a connection can be established

      exec /etc/init.d/samba start

      ;;

   'down')

      # do something when connection gets lost?

      # exec /etc/init.d/samba stop

      ;;

esac

```

name it '10-samba' or something and drop it into /etc/NetworkManager/dispatcher.d' (don't forget to chmod +x !!)

Samba should only be started now once a connection could be established now.

By the way there are pretty good tips on speeding up dhcp and more on the arch wiki page: https://wiki.archlinux.org/index.php/NetworkManager#Network_Services_with_NetworkManager_Dispatcher

----------

## Tom_

I disabled ARP probing in dhcpcd as advised on the Arch wiki. This solves my problem for the moment.

Thanks

----------

