You are not logged in.
If you have a simple wired connection or a fixed wireless access point, there is no need for NetworkManager.
The intrinsic networking functionality of systemd can be used instead with less overhead (15-20 MiB saving in my set up).
Throughout this guide, "wlan0" & "eth0" are used to refer to the interface names -- change these to match your system if necessary (view all interface names with `ip link`).
Firstly, create the configuration files (as root!):
Nameserver resolution is set through /etc/systemd/resolved.conf but it will default to your Gateway (ie, router) and only needs changing if you want to use something else.
To connect via ethernet, use /etc/systemd/network/10-wired.network
[Match]
Name=eth0
[Network]
DHCP=ipv4
For wireless connections use /etc/systemd/network/20-wireless.network
[Match]
Name=wlan0
[Network]
DHCP=ipv4
For combined wired/wireless with a seamless switchover between the two when the cable is un/plugged, add this stanza below the [Network] block in each file:
[DHCP]
RouteMetric=XX
Replace "XX" with "10" for 10-wired.conf and "20" for 20-wireless.conf to ensure that the wired connection is favoured.
For static addresses, use this template after the [Match] section (adjust to fit, obviously):
[Network]
Address=192.168.69/24
[Route]
Gateway=192.168.1.1
Metric=10
To associate with wireless access points, create a configuration file for your access point by using:
sudo bash -c "wpa_passphrase SSID password >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf"
Replace "SSID" with the name of the access point (use `iwlist wlan0 scan|grep SSID` to list all access points) and replace "password" with the, er, password.
Repeat the `wpa_passphrase` command for all access points, these can be added later as needed.
Now create a systemd unit file at /lib/systemd/system/wpa_supplicant@.service (as root!) with the following content:
[Unit]
Description=WPA supplicant daemon (interface-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=simple
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I
[Install]
Alias=multi-user.target.wants/wpa_supplicant@%i.service
You will also need to overwrite /etc/resolv.conf with a symlink (start the resolved.service first):
sudo systemctl start systemd-resolved
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
Finally, enable all the relevant .services and disable NetworkManager & rename nm-applet.desktop to stop it autostarting:
sudo systemctl enable systemd-networkd systemd-resolved wpa_supplicant@wlan0
sudo systemctl disable {Network,Modem}Manager NetworkManager-dispatcher
sudo mv /etc/xdg/autostart/nm-applet.desktop{,.bak}
Now Reboot.
To switch from systemd-networkd to NetworkManager and back , set these aliases in your shell configuration file:
# ~/.bashrc or ~/.zshrc
alias netman='/usr/bin/sudo bash -c "systemctl stop systemd-networkd systemd-resolved wpa_supplicant@wlan0 && ip a flush wlan0 && systemctl start {Network,Modem}Manager NetworkManager-dispatcher && nm-applet &"'
alias unetman='/usr/bin/sudo bash -c "systemctl stop {Network,Modem}Manager NetworkManager-dispatcher && killall nm-applet && ip a flush wlan0 && systemctl start systemd-networkd systemd-resolved wpa_supplicant@wlan0"'
Then use `netman` & `unetman` in a terminal -- it takes a few seconds to switch and will show/kill the systray icon.
Alternatively, install the wpagui package and run the wpa_gui(8) command to start a systray-activated GUI that can be used to select and edit connection details.
To revert back to NetworkManager permanently, rename /etc/xdg/autostart/nm-applet.desktop.bak and run these commands and reboot:
sudo systemctl disable systemd-networkd systemd-reseolved wpa_supplicant@wlan0
sudo systemctl enable {Network,Modem}Manager NetworkManager-dispatcher
Last edited by Head_on_a_Stick (2017-10-22 12:09:17)
Offline
systemd is really developing fast.
when i started with it, netctl was still a seperate application.
( the same goes for ntp, recent systemd versions have this functionality built in )
btw, my wired connection "just works", my /etc/systemd/network folder is empty...
Offline
btw, my wired connection "just works", my /etc/systemd/network folder is empty...
That's because you have dhcpcd.service (or the interface-specific version) enabled.
Check with:
systemctl list-unit-files|grep enabled
systemd-networkd uses the in-built DHCP mechanism and can be used with static IPs instead.
https://wiki.archlinux.org/index.php/Sy … _static_IP
Offline
thanks HoaS, i was looking for that oneliner but kinda tired last night... dhcpcd is not running, and nothing else network related.
i should've mentioned that this is on my arch system, which runs on systemd 227; debian stable is on 215.
for the benefit of others, what HoaS describes works & is the best way to go if you want to get rid of network manager on bunsenlabs!
Offline
Thanks for posting this, Head_on_a_Stick!
the best way to go if you want to get rid of network manager on bunsenlabs
It's one way to go, and that's if you have a fixed access point, as HoaS said. It's pretty useless if you're on a laptop and are using multiple access points (home, library, coffee shop, friend's house, etc...) unless you feel like manually configuring your wireless every time you switch networks.
I need some enlightenment. If it's a fixed access point, why is this better than configuring /etc/network/interfaces, which is simpler to configure? Also, I just looked and the Debian Wiki page "WiFi/HowToUse" and the instructions for WiFi using wpa_supplicant and /etc/network/interfaces have changed...
https://wiki.debian.org/WiFi/HowToUse#wpa_supplicant
Their /interfaces example used to look like this...
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
wpa-ssid mynetworkname
wpa-psk mysecretpassphrase
Restrict permissions on the file...
sudo chmod 0600 /etc/network/interfaces
Reboot, done. Or you can bring up the interface without needing to reboot...
sudo ifup wlan0
Now it asks you to generate the actual passkey and use that. Easily done, but why bother with the extra step?
I use ceni, which is an ncurses interface that can scan for networks and configure wpa_supplicant for you "on the fly", meaning, of course, that you can easily switch networks when you try out that new coffee house that offers free WiFi. It's not available in Debian, but it's easily backported from the siduction repository. I'd argue that this is a much easier and more flexible solution than manually configuring either wpa_supplicant or systemd.
The /etc/network/interfaces file it generates is the same as the one I posted above except that 'auto wlan0' is replaced wih 'allow-hotplug wlan0'.
Finally, for the convenience of it's GUI, having an applet in the systray that shows you signal strength and auto-connecting to known networks, nm-applet is well worth the few extra MBs of RAM it uses.
No, he can't sleep on the floor. What do you think I'm yelling for?!!!
Offline
I think one of the main reasons to set it up through systemd is because when you use /etc/network/interfaces it blocks boot. The 30 seconds it takes to configure the network is an eternity when your entire system boots in less than 7 seconds. Also, if you are attempting to set up container through systemd-nspawn, you need the connection setup through systemd in order to share it into the container. Systemd's networking components are really only designed for non-mobile access. For mobile access, they still recommend network manager. Having said that, when I need quick and dirty access, I still use /etc/network/interfaces as it only takes a few seconds to get it running. However, it is not at all designed for fast parallel-ized startups.
Offline
^OK, that makes sense. I'd guesstimate it's about 5 seconds for my network to come up using ceni/wpa_supplicant, but I could see wanting to save a few seconds if I was, say, on a desktop using wireless that would need to be configured only once.
Thanks for the input. *thumbs up*
No, he can't sleep on the floor. What do you think I'm yelling for?!!!
Offline
It's pretty useless if you're on a laptop and are using multiple access points (home, library, coffee shop, friend's house, etc...) unless you feel like manually configuring your wireless every time you switch networks.
I use these aliases in my shell configuration file to switch to NetworkManager and back:
# ~/.bashrc or ~/.zshrc
alias netman='/usr/bin/sudo bash -c "systemctl stop systemd-networkd systemd-resolved wpa_supplicant@wlan0 && ip a flush wlan0 && systemctl start NetworkManager NetworkManager-dispatcher && nm-applet &"'
alias unetman='/usr/bin/sudo bash -c "systemctl stop NetworkManager NetworkManager-dispatcher && killall nm-applet && ip a flush wlan0 && systemctl start systemd-networkd systemd-resolved wpa_supplicant@wlan0"'
It takes a few seconds to switch and will show/kill the systray icon
EDIT: Added to OP
Offline
To quote a post I just made re: your last screenshot... Nice!
No, he can't sleep on the floor. What do you think I'm yelling for?!!!
Offline
I have chosen the systemd-networkd approach for my ethernet connected BunsenLabs machine.
I think this procedure is much the same;
http://xmodulo.com/switch-from-networkm … workd.html
Network is working OK so far...
Offline
I finally got this to work. However, I noticed one small thing. At first, I wasn't getting any name resolution after following the walkthrough. Then I noticed /etc/systemd/resolved.conf and took a look at it. It showed this:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
#DNS=
#FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
#LLMNR=yes
I modified it too look like this:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
#FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
#LLMNR=yes
rebooted and everything works as expected now.
Thanks for the walkthrough. It is doubtful I would have figured all of that out on my own.
Offline
^ Thanks for the feedback tk!
Glad you got it working
Did you check the content of /etc/resolv.conf before correcting the resolved.conf file?
I had trouble getting resolved to obey the settings in that file and now define the DNS in the .network files.
I will change the OP to reflect this.
EDIT: Changed.
Last edited by Head_on_a_Stick (2016-02-04 18:38:58)
Offline
I had it symlinked to /run/systemd/resolve/resolv.conf. A check of that file showed two nameserver listings as so:
nameserver 8.8.8.8
nameserver 8.8.4.4
which I assume it picked up from a hardcoded /etc/resolv.conf as I was routing around an error that blew up NetworkManager on Sid, so I was not using the values stored in the /run directory for name resolution, as the error that was coming up could not find the file there.
To be clear: I first setup an /etc/network/interfaces setup and modified /etc/resolv.conf before I ran through your walkthrough so that could be part of it.
Offline
To be clear: I first setup an /etc/network/interfaces setup and modified /etc/resolv.conf before I ran through your walkthrough so that could be part of it.
Yeah, could be.
It's best to just delete /etc/resolv.conf then start systemd-resolved.service then symlink /run/systemd/resolve/resolv.conf to /etc/resolv.conf
Be sure to comment out the non-loopback lines in /etc/network/interfaces
Offline
Offline
Bumping this thread because I have updated and improved the guide, adding details for the correct nameserver configuration and a section on static addresses.
It is also worth noting that any Helium-dev (or Debian stretch/testing/unstable) users can now employ the provided /etc/systemd/system/wpa_supplicant@.service and so don't have to create their own local version.
Offline