Ask Your Question

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

asked 2012-07-11 08:34:00 +0000

wis775 gravatar image

updated 2012-08-05 07:17:50 +0000

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
After=syslog.target local-fs.target network.target

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 17:43:34.165385



Short answer:

systemctl enable NetworkManager-wait-online.service

Long answer:


lennart ( 2013-02-14 16:36:49 +0000 )edit

Thanks, that works on Fedora 19!

Fanaz ( 2013-08-04 09:34:56 +0000 )edit

3 answers

Sort by ยป oldest newest most voted

answered 2012-08-06 16:37:02 +0000

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-10-31 18:26:38 +0000

sergeygals gravatar image

updated 2013-10-31 18:27:29 +0000

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 ( 2014-01-01 16:58:37 +0000 )edit

answered 2013-07-05 17:56:03 +0000

Emmanuel Touzery gravatar image

updated 2013-07-05 18:05:08 +0000

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/minidlna.pid

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.

steveebey73742 ( 2017-03-14 01:19:56 +0000 )edit

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

1 follower


Asked: 2012-07-11 08:34:00 +0000

Seen: 17,957 times

Last updated: Oct 31 '13