i'm new to systemd, very used to ubuntu\debian RC system scripts so i'm a bit confused. the basic idea was to setup static ip for my raspberry pi ncluding dns etc... naturally editing /etc/networking/interface does nothing as systemd-networkd is doing network configuration now. But checking out /lib/systemd/network/ reveals:

pi@gal-pi:~ $ ls -l /lib/systemd/network/
total 12
-rw-r--r-- 1 root root 368 Jan 24 12:02 80-container-host0.network
-rw-r--r-- 1 root root 378 Jan 24 12:02 80-container-ve.network
-rw-r--r-- 1 root root  73 Jan 24 12:02 99-default.link

I have two interfaces on my pi eth0 which is connected and i want to set with static ipv4 and wlan0. wlan0 doesn't get anything really and didn't bother to even try t set him up, eth0 however get's dhcp address. Non of the scripts above seem to setup dhcp.


pi@gal-pi:~ $ ls -l /etc/systemd/system/dhcpc*
lrwxrwxrwx 1 root root   34 Mar 18 08:15 /etc/systemd/system/dhcpcd5 -> /lib/systemd/system/dhcpcd.service

So there is a systemd dhcp service that is started on boot.bringing me to my questions:

  1. should i setup dhcps service using dhcpcd.conf to setup static address on eth0 ?
  2. should i use /etc/lib/systemd/network/40-eth0-static.network to setup the static address ?
  3. how do i know who runs first dhcpd or networkd ? so they wont override each other ? i know systemd can be distributed in that it can run in parallel several services...
  4. any other method i should use to setup static ip properly ?
  5. if i'm at it do i need to use the same systemd-networkd scripts to setup wireless lan ? and if it's a hotspot (using hotap)
  • can't u just set up ur static ip on your router? that's what I did – nafas Apr 11 '16 at 16:26
  • linksys WRT-54G does not have dhcp mac address association. so no :-) i need to set it up. saw multiple answers here bu my no #3 is still a good question. – codeScriber Apr 11 '16 at 16:58

1.: No idea whether you can set up static IP with dhcpcd or dhclient. Doesn't sound making sense though (I mean, why?).

2. You should have a SOMENAME.network file in /etc/systemd/network. SOMENAME doesn't have to be 40-eth0-static. Although ordering the .network files with number prefix might be necessary under certain circumstances (but obviously not when you only have one).

3.: You should NOT run multiple network agents. This has nothing to do with distributed or parallel several services at all. They will conflict with each other since they essentially do the same thing. So use EITHER systemd-networkd OR dhcp"c"d (OR something else).

4.: It's up to you. You can use NetworkManager or so instead.

5.: AFAIK systemd-networkd cannot be used to set up Wi-Fi connection (e.g. connect to an SSID and authenticate to it). However, you can use it in companion with wpa_supplicant for IP address and so after the connection/authentication. This doesn't count as multiple network agents, since they do different stuff.

  • almost complete answer :-) the issue is, regarding your answer for #3, i didn't set up anything, rasberrian comes with dhcpd service running and networkd running, i get already dhcp for eth0 and 100% networkd is not responsible for it, so it's just dhcpd's doing, according to what you wrote i need to first disable dhcpd for eth0 before i add comfiguration, how do i do that ? – codeScriber Apr 12 '16 at 6:14
  • ok. so from wandering around much data and raspberry pi forums it seems that: 1. systemd should still use /etc/network/interfaces 2. in that file it states i should use dhcpcd.conf 3. the reason is probably that in systemd there is a race between defaul dhcpccd service running and system which sets up the interfaces so setting it up in /etc/hdcpcd.conf solved the problem 4. the other approach would be to use hdcpcd@wlan0 target to still allow dhcpcd in the system and disable the main service and set it static using systemd /etc/network – codeScriber Apr 16 '16 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.