Ask Your Question

How to start a systemd service, after DHCP has initialized the IP-Adress? [closed]

asked 2012-07-11 03:34:00 -0500

wis775 gravatar image

updated 2012-08-05 02:17:50 -0500

I have installed minidlna from the rpmfusion-free repository and it doesn't start sucessfully via systemd at system startup.

The start of minidlna via terminal does work.

sudo systemctl start minidlna.service

The short story

My system gets the IP-Adress via DHCP and it seems, that minidlna tries to start, at a time, when still no IP-Adress is assigned to my system through DHCP.

The long story:

With the installation, i got a minidlna.service configuration like this.


Description=MiniDLNA is a DLNA/UPnP-AV server software

ExecStart=/usr/sbin/minidlna -f /etc/minidlna.conf


I enabled the service via

sudo systemctl enable minidlna.service

Now, minidlna is trying to start during system startup and fails to start.

This is the status:

sudo systemctl status minidlna.service
minidlna.service - MiniDLNA is a DLNA/UPnP-AV server software
      Loaded: loaded (/usr/lib/systemd/system/minidlna.service; enabled)
      Active: failed (Result: exit-code) since Wed, 11 Jul 2012 09:13:13 +0200; 1h 2min ago
     Process: 782 ExecStart=/usr/sbin/minidlna -f /etc/minidlna.conf (code=exited, status=1/FAILURE)
      CGroup: name=systemd:/system/minidlna.service

Looking in messages.log, i see, that there must be a problem with the network interface.

NetworkManager[716]: <info> dhclient started with pid 808
NetworkManager[716]: <info> Activation (em1) Stage 3 of 5 (IP Configure Start) complete.
minidlna.service: control process exited, code=exited status=1
minidlna.c:369: No MAC address found.  Falling back to generic UUID.
getifaddr.c:113: error: Network interface eth0 not found
getifaddr.c:113: error: Network interface eth1 not found
minidlna.c:758: No IP address automatically detected!
dhclient[808]: DHCPREQUEST on em1 to port 67 (xid=0x754a3b86)
dhclient[808]: DHCPACK from (xid=0x754a3b86)
NetworkManager[716]: <info> (em1): DHCPv4 state changed preinit -> reboot

The IP-Adress is assigned via DHCP to my system and the messages.log indicates, that the NetworkManager has not finished all steps, when minidlna tries to start.

I think, the overall question must be - How to enforce minidlna, that it starts, after the NetworkManager has completed his work?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Akshay
close date 2013-11-01 12:43:34.165385



Short answer:

systemctl enable NetworkManager-wait-online.service

Long answer:

lennart gravatar imagelennart ( 2013-02-14 10:36:49 -0500 )edit

Thanks, that works on Fedora 19!

Fanaz gravatar imageFanaz ( 2013-08-04 04:34:56 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2012-08-06 11:37:02 -0500

ZenDark gravatar image

In the "After" try adding:

That's the name of the NetworkManager service which controls your card and the dhclient.

edit flag offensive delete link more

answered 2013-07-05 12:56:03 -0500

Emmanuel Touzery gravatar image

updated 2013-07-05 13:05:08 -0500

Well, on fedora 19 the other solutions didn't work for me (well I didn't try the one that delays all services just for that... I only want to delay minidlna because it's the only problematic service), so i gave up and went for the ugly-but-it-works solution.

I wrote this script:

ip_row=`ifconfig | grep 192`
while [ ! -n "$ip_row" ]
  ip_row=`ifconfig | grep 192`
  sleep 2

# OK now there an IP...
/usr/sbin/minidlna -f /etc/minidlna.conf -P /var/run/minidlna/

I know my IP is going to be 192.*, so I relied on that. Once ifconfig returns at least one row containing "192" i know I have an IP. So I make a loop and once I have an IP then I launch minidlna. Works for me.

So then in /usr/lib/systemd/system/minidlna.service I changed the ExecStart row to start this script instead of starting minidlna directly.

Remember to give exe rights to that script (chmod 755), and you can debug any problems by checking in /var/log/messages and by running the very helpful systemctl status command.

edit flag offensive delete link more


if you only have one network card, comment out the network interface= in the /etc/minidlna.conf file as the default is to listen on all interfaces. Most people do not have more than one network card in there computers. works fine for me.

SteveEbey73701 gravatar imageSteveEbey73701 ( 2017-03-13 20:19:56 -0500 )edit

answered 2013-10-31 13:26:38 -0500

sergeygals gravatar image

updated 2013-10-31 13:27:29 -0500

or just add



into the [Service] in the /usr/lib/systemd/system/minidlna.service

edit flag offensive delete link more


works perfect on Fedora 20 too. Many thanks!

li737 gravatar imageli737 ( 2014-01-01 10:58:37 -0500 )edit

Question Tools

1 follower


Asked: 2012-07-11 03:34:00 -0500

Seen: 22,403 times

Last updated: Oct 31 '13