You are not logged in.

#1 2014-03-17 06:24:58

hendry
Member
From: Singapore
Registered: 2009-09-08
Posts: 157
Website

Managing WPA wireless with systemd-networkd ?

Hi guys,

I've moved to systemd-networkd to manage my wired interface. smile

http://dabase.com/blog/Good_riddance_netctl/

Has anyone successfully managed to get their /etc/wpa_supplicant.conf working through  systemd-networkd too?

Offline

#2 2014-03-17 17:11:10

Everdras
Member
Registered: 2012-09-13
Posts: 35

Re: Managing WPA wireless with systemd-networkd ?

I thought the designer of networkd specifically said that he envisioned this only for servers and desktops (where the details of the connection don't change), and not for laptops, where things like networkmanager do a better job?

Offline

#3 2014-03-17 17:29:22

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Managing WPA wireless with systemd-networkd ?

Just use wpa_supplicant@.service (have it point to the right wpa_supplicant*.conf file).  systemd-networkd detects interfaces coming up or down, so whenever the association occurs, it should detect it and set it up apropriately.  I was using this method for a few days and it works flawlessly.  But then I set up ipv6, and systemd-networkd has a ways to go as far as ipv6.

Offline

#4 2014-03-18 02:56:59

hendry
Member
From: Singapore
Registered: 2009-09-08
Posts: 157
Website

Re: Managing WPA wireless with systemd-networkd ?

WonderWoofy wrote:

Just use wpa_supplicant@.service (have it point to the right wpa_supplicant*.conf file).  systemd-networkd detects interfaces coming up or down, so whenever the association occurs, it should detect it and set it up apropriately.  I was using this method for a few days and it works flawlessly.  But then I set up ipv6, and systemd-networkd has a ways to go as far as ipv6.

I tried wpa_supplicant@wlan0.service, but it was missing the IP address. But once I enabled dhcpcd@wlan0.service, I noticed /usr/lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant and hence there doesn't seem to be a need for wpa_supplicant@wlan0.service!?

I updated my blog accordingly http://dabase.com/blog/Good_riddance_netctl/ and commented on a couple of dhcpcd bugs https://bugs.archlinux.org/?project=1&c … ing=dhcpcd

Offline

#5 2014-03-18 02:58:20

hendry
Member
From: Singapore
Registered: 2009-09-08
Posts: 157
Website

Re: Managing WPA wireless with systemd-networkd ?

Everdras wrote:

I thought the designer of networkd specifically said that he envisioned this only for servers and desktops (where the details of the connection don't change), and not for laptops, where things like networkmanager do a better job?

There is mention of wireless in https://coreos.com/blog/intro-to-systemd-networkd/ which led me to ask about wireless. I'm not using networkmanager because of bloat blah blah. wink

Offline

#6 2014-03-18 03:35:39

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Managing WPA wireless with systemd-networkd ?

Okay, so I'll walk you through this since there is really not a whole lot of documentation on the subject.  This assumes that your NIC is wlan0, your SSID is MyNetwork, and the password is SuperSecretPassphrase.

You need to create a wpa_supplicant-wlan0.conf.  So use wpa_passphrase to generate one:

# wpa_passphrase MyNetwork SuperSecretPassphrase > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

Enable it so that it runs on boot:

# systemctl enable wpa_supplicant@wlan0.conf

Now make a file at /etc/systemd/network/00-wireless-dhcp.network (it can really be named whatever you want):

[Match]
Name=wlan0

[Network]
DHCP=yes

Now ensure that systemd-networkd.service is enabled.

# systemctl enable systemd-networkd.service

Reboot, and it should be working.

Edit: cleanup

Edit2: Okay, that is not working for me either...

Edit3: Okay nevermind, I just made a typo and named my file 00-wireless-dhcp.ntwork tongue

Edit4: I forgot to mention that you also need to ensure that /etc/resolv.conf is a symlink to /run/systemd/network/resolv.conf.  As a hack (since I don't use systemd-networkd regularly) I have the following:

$ cat /etc/systemd/system/systemd-networkd.service.d/resolv.conf
[Service]
ExecStartPost=/usr/bin/ln -sf /run/systemd/network/resolv.conf /etc/resolv.conf
ExecStopPost=/usr/bin/rm /etc/resolv.conf
ExecStopPost=/usr/bin/touch /etc/resolv.conf 

Last edited by WonderWoofy (2014-03-18 03:55:59)

Offline

#7 2014-03-18 05:46:35

hendry
Member
From: Singapore
Registered: 2009-09-08
Posts: 157
Website

Re: Managing WPA wireless with systemd-networkd ?

Thanks WonderWoofy. This is AWESOME!

I've also since updated http://dabase.com/blog/Good_riddance_netctl/


Some little comments:

`sudo systemctl enable wpa_supplicant@wlan0.service` not as you have it `# systemctl enable wpa_supplicant@wlan0.conf`

When my machine comes up on wired, both wireless and wired interfaces come up. eth0 since seems to get used judging by the routing table.

If I then unplug eth0, I hoped it would just use wlan0, but it doesn't, I just get

sudo ip route get 8.8.8.8                                                                                                       
RTNETLINK answers: Network is unreachable

Workaround for me is to simply use the hardware wifi switch, off and on, and I'm back online. smile

I really think this is the way forward. I wonder where https://wiki.archlinux.org/ this information should live.

Offline

#8 2014-03-18 06:09:32

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Managing WPA wireless with systemd-networkd ?

'#' is a representation of the root user's shell.  So yes, you can achieve the same thing by using 'sudo' but however you elevate yourself to root is fine.
(In bash and sh the normal user's shell is represented by a '$', while in ksh and zsh the normal user is '%')

If it is trying to configure the wired interface, then you must have something else trying to use it.  The first section of the systemd.network file (the [Match] section) should make it so that it only acts on the interface in question.  In this case it is the Name=wlan0. 

If you think you might want to use predictable network interface naming, the wireless devices will all start with a 'w' and the wired/ethernet with an 'e'.  So for any potential wireless device you could also use globbing and simply put 'Name=w*'.

Offline

#9 2014-03-18 07:30:51

progandy
Member
Registered: 2012-05-17
Posts: 5,266

Re: Managing WPA wireless with systemd-networkd ?

WonderWoofy wrote:

If you think you might want to use predictable network interface naming, the wireless devices will all start with a 'w' and the wired/ethernet with an 'e'.  So for any potential wireless device you could also use globbing and simply put 'Name=w*'.

Better use "wl*". wwan interfaces start with ww.
http://www.freedesktop.org/wiki/Softwar … faceNames/
http://cgit.freedesktop.org/systemd/sys … t_id.c#n20


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#10 2014-03-18 12:56:11

frank
Member
From: Karlsruhe/Germany
Registered: 2014-02-06
Posts: 8

Re: Managing WPA wireless with systemd-networkd ?

WonderWoofy wrote:

'#' is a representation of the root user's shell.  So yes, you can achieve the same thing by using 'sudo' but however you elevate yourself to root is fine.
(In bash and sh the normal user's shell is represented by a '$', while in ksh and zsh the normal user is '%')

IMHO, it's not only the 'sudo', it's also wpa_supplicant@wlan0.service vs. wpa_supplicant@wlan0.conf in your systemctl command line ;-)

Offline

#11 2014-03-18 14:28:08

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Managing WPA wireless with systemd-networkd ?

frank wrote:

IMHO, it's not only the 'sudo', it's also wpa_supplicant@wlan0.service vs. wpa_supplicant@wlan0.conf in your systemctl command line ;-)

This is the ExecStart line from wpa_supplicant@.service:

ExecStart=/usr/bin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I

So you can't use wpa_supplicant@wlan0.conf unless you name the file /etc/wpa_supplicant/wpa_supplicant-wlan0.conf.conf.

Last edited by WonderWoofy (2014-03-18 14:28:24)

Offline

#12 2014-03-18 17:13:42

sekret
Member
Registered: 2013-07-22
Posts: 289

Re: Managing WPA wireless with systemd-networkd ?

WonderWoofy wrote:

Okay, so I'll walk you through this since there is really not a whole lot of documentation on the subject.  This assumes that your NIC is wlan0, your SSID is MyNetwork, and the password is SuperSecretPassphrase.

You need to create a wpa_supplicant-wlan0.conf.  So use wpa_passphrase to generate one:

# wpa_passphrase MyNetwork SuperSecretPassphrase > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

Enable it so that it runs on boot:

# systemctl enable wpa_supplicant@wlan0.conf

Now make a file at /etc/systemd/network/00-wireless-dhcp.network (it can really be named whatever you want):

[Match]
Name=wlan0

[Network]
DHCP=yes

Now ensure that systemd-networkd.service is enabled.

# systemctl enable systemd-networkd.service

Reboot, and it should be working.

Edit: cleanup

Edit2: Okay, that is not working for me either...

Edit3: Okay nevermind, I just made a typo and named my file 00-wireless-dhcp.ntwork tongue

Edit4: I forgot to mention that you also need to ensure that /etc/resolv.conf is a symlink to /run/systemd/network/resolv.conf.  As a hack (since I don't use systemd-networkd regularly) I have the following:

$ cat /etc/systemd/system/systemd-networkd.service.d/resolv.conf
[Service]
ExecStartPost=/usr/bin/ln -sf /run/systemd/network/resolv.conf /etc/resolv.conf
ExecStopPost=/usr/bin/rm /etc/resolv.conf
ExecStopPost=/usr/bin/touch /etc/resolv.conf 

This needs to go to the wiki!

Offline

#13 2014-03-18 17:17:17

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Managing WPA wireless with systemd-networkd ?

sekret wrote:
WonderWoofy wrote:
Stuuuuuufff

This needs to go to the wiki!

I have to head off to work in a minute here.  But you're welcome to submit this information to the wiki if you please.  Otherwise I'll do it later when I get a minute.

Offline

#14 2014-03-19 22:58:49

cris9288
Member
Registered: 2013-01-07
Posts: 348

Re: Managing WPA wireless with systemd-networkd ?

hendry wrote:

Hi guys,

I've moved to systemd-networkd to manage my wired interface. smile

http://dabase.com/blog/Good_riddance_netctl/

Has anyone successfully managed to get their /etc/wpa_supplicant.conf working through  systemd-networkd too?


I'd be interested in hearing how this goes for you. I was using systemd-networkd for a couple of days and it worked great, but it suddenly stopped working. I was using it at work, then I put it to sleep and when I woke it at home it was unable to get a connection. Journalctl says something along the lines of "couldn't save link data /run/systemd/network/links/{1, 2, 3} no such file or directory. Am curious to know if that happens to you.

Offline

#15 2014-10-13 20:28:02

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,912
Website

Re: Managing WPA wireless with systemd-networkd ?

Please note that you need to run systemd-resolved to allow symlinks for /etc/resolve.conf to work. It is of course mentioned on wiki page for systemd-networkd.

sorry if this is considered bumping an old thread.


Mr Green

Offline

#16 2014-11-07 07:58:23

enihcam
Member
From: Internet
Registered: 2009-12-20
Posts: 220

Re: Managing WPA wireless with systemd-networkd ?

This thread needs to go to the wiki.

Offline

#17 2014-11-08 17:55:41

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Managing WPA wireless with systemd-networkd ?

enihcam wrote:

This thread needs to go to the wiki.

You should put it in the wiki then.  I'm just not entirely sure where to put it.  Maybe you could just link back to this thread from the bottom of the wpa_supplicant and systemd-networkd pages?

Offline

#18 2014-11-08 18:15:38

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Managing WPA wireless with systemd-networkd ?

WonderWoofy wrote:

Maybe you could just link back to this thread from the bottom of the wpa_supplicant and systemd-networkd pages?

This.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#19 2014-11-09 14:47:16

serdotlinecho
Member
Registered: 2013-01-26
Posts: 100

Re: Managing WPA wireless with systemd-networkd ?

I've been using systemd-networkd with wpa_supplicant for 2 months now on my laptop and it works great. Btw, I followed the tutorial from this blog.

$ networkctl list
IDX LINK             TYPE               OPERATIONAL SETUP     
  1 lo               loopback           carrier     unmanaged 
  2 enp9s0           ether              off         unmanaged 
  3 wlp5s0           wlan               routable    configured
$ networkctl status wlp5s0
● 3: wlp5s0
        Type: wlan
       State: routable (configured)
        Path: pci-0000:05:00.0
      Driver: wl0
      Vendor: Broadcom Corporation
       Model: BCM4313 802.11bgn Wireless Network Adapter
  HW Address: XX:XX:XX:XX:XX:XX
         MTU: 1500
     Address: 192.168.1.4
              XXXX::XXXX:XXXX:XXXX:XXXX
         DNS: 192.168.1.1

Offline

Board footer

Powered by FluxBB