Skip to content

Instantly share code, notes, and snippets.

@jjsanderson
Last active April 20, 2023 17:25
Show Gist options
  • Star 62 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save jjsanderson/ab2407ab5fd07feb2bc5e681b14a537a to your computer and use it in GitHub Desktop.
Save jjsanderson/ab2407ab5fd07feb2bc5e681b14a537a to your computer and use it in GitHub Desktop.
Installing Network Manager on Raspbian 2020-02-05

Installing Network Manager on Raspbian 2020-02-05

NOTE:
This guide was written more than two years ago, which in Pi years means it's now graduated college, or something. Inevitably, it's at least a little out of date, and it may even be entirely misleading. There are several helpful suggestions in the comments (thanks everyone), and most recently a report that what's here plain doesn't work on current (early 2022) Raspbian. Which isn't even called 'Raspbian' any more.
As of Jan 2022 I'm partially back in my office-which-has-access-to-eduroam, and I do have a need to build up a fresh Pi desktop. If and when I get that working I'll update this guide. In the meantime: good luck, and please leave a comment to report success or failure.
(June 2022) Nope, I still haven't actually tried any of this myself. However, I have had to troubleshoot eduroam wifi on my Linux ThinkPad. As of Ubuntu 22.04 it would no longer connect. This Stack Exchange answer explains why, and the steps necessary to re-enable some old and busted negotiation stuff to get it going again. I've had to repeat the fix on a fresh Pop! OS (22.04) install. I've no idea if the same issue might arise with Raspberry Pi OS, but at some point it likely will so I'm pasting the link here to remind myself of it.
(September 2022) It looks like the latest release of Raspberry Pi OS now offers Network Manager as an option. You still have to enable it, but that's now integrated with raspi-config, which will hopefully render this guide redundant.

OLD AND PROBABLY OBSOLETE NOTES:

Default Raspbian is not able to connect to wifi networks using corporate security setups, including eduroam. However, the issue is that the packaged networking control widget does not expose the relevant security features, rather than any underlying hardware limitation. The solution has long been to install Network Manager and configure it to handle the wifi interface.

Unfortunately, previous installation approaches didn't work for me on the Raspbian 2020-02-06 image. Following a fresh install, the below is what I did to make it work. Note that this is actually simpler than previous recipes.

Install packages

sudo apt update
sudo apt install network-manager network-manager-gnome

Configure dhcpcd to ignore wlan0

Check /etc/network/interfaces; this should be empty except for an include from /etc/network/interfaces.d (which is in turn empty).

Edit /etc/dhcpcd.conf, add line:

denyinterfaces wlan0

Back at the prompt, at this point I did sudo systemctl restart dhcpcd. Which probably isn't strictly necessary, since we're shortly going to reboot anyway.

Configure Network Manager to control wlan0 and assume dhcp duties

edit /etc/NetworkManager/NetworkManager.conf:

[main]
plugins=ifupdown,keyfile
dhcp=internal

[ifupdown]
managed=true

Restart

sudo reboot

Done

At this point, you should have two wifi widgets in the menu bar: the default Raspbian one, showing two red crosses and 'No wireless interfaces found' when clicked, and Network Manager with a full pull-down menu. Once a wifi ssid is selected, the connection dialogue should expose full security settings (PEAP, etc.), allowing access to a wider range of networks.

You can remove the now-defunct default wifi widget by right-clicking the menubar and selecting 'Panel Settings -> Panel Applets'.

Alternatives

Thanks to @aallan for this: it's also possible to bypass all the above and edit wpa_supplicant.conf directly. For eduroam, for example:

network={
  ssid="eduroam"
  scan_ssid=1
  key_mgmt=WPA-EAP
  eap=PEAP
  identity="your_username"
  password="your_password" phase1="peaplabel=0"
  phase2="auth=MSCHAPV2"
}

You can combine this with dropping a wpa_supplicant.conf file in /boot to have the Pi connect on boot, which is particularly useful for headless Pis. Alasdair has a more detailed write-up.

@thoschworks
Copy link

I have set up Network Manager successfully and tried to connect to the VPN of our university. However, I cannot find where to log in with my specific username and password so the connection always fails.

There are modules for the different types of vpn. You have to know which vpn is used and look for the appropriate module. And there no modules for some sort of vpn.

And without knowing the type of the vpn we cannot help you.

The IT-Support of our university explained that I have to use a 64-bit software. Is there any way to solve my issue on 32-bit Raspbian?

I don't see any reason that the client side has to be a 64-bit system. The network connection is only 8 bit…

@bilal-61
Copy link

The IT-Support of our university explained that I have to use a 64-bit software. Is there any way to solve my issue on 32-bit Raspbian?

I don't see any reason that the client side has to be a 64-bit system. The network connection is only 8 bit…

That's good to hear at least. They have told me that they had experienced problems on 32-bit systems before but they might just be lazy i guess 😝

I have set up Network Manager successfully and tried to connect to the VPN of our university. However, I cannot find where to log in with my specific username and password so the connection always fails.

There are modules for the different types of vpn. You have to know which vpn is used and look for the appropriate module. And there no modules for some sort of vpn.

And without knowing the type of the vpn we cannot help you.

What exactly do you mean by "module"? I can tell I selected Cisco Anyconnect compatible openconnect, I have entered the gateway and the certificate. Every student received a username and password for log in which is the only information I cannot enter in the program. Any kind of "log-in-screen" does not appear. Which should, when trying to connect. All that is shown is the error message and the error log

@krisnand
Copy link

Hi Everyone,

Thanks @jjsanderson for posting this up.

I've got Network Manager installed on a fresh install of Raspbian but running into a few issues (which might be related?).

  1. Every time I click on the Network Manager Icon, an 'Authentication' box pops up asking for the password for either root or the pi user. Dialogue box reads "System policy prevents control of network connections". Goes away and lets me do things when I enter in pi's password. Comes back again the next time I try doing something. Is this normal?

Screen Shot 2021-01-13 at 4 35 40 pm

  1. When I right click the Network Manager icon and click "Edit Connections...", the Network Connections dialogue that pops up doesn't let me edit (using the gear icon below) my current connections. It let's me click on the + icon below to add a connection but once I select what connection type I'd like to create, the next page that pops up is completely greyed out and does not let me edit/save the connection.

Screen Shot 2021-01-13 at 4 37 52 pm

Screen Shot 2021-01-13 at 4 38 30 pm

Any help would be appreciated!

@jjsanderson
Copy link
Author

@krisnand Are you attempting to use wired Ethernet? The denyinterfaces wlan0 line in the recipe above disables dhcpcd for the wifi interface only, it'll still be the active for ethernet. You'd need to add deny interfaces eth0 (or eth1?) to /etc/dhcpcd.conf to achieve the same thing on that interface. I've no idea if that would work - my usual workplace would throw a fit if I plugged my own stuff into their wired network - but I'd expect it should.

Alternatively, it's entirely possible that this guide is getting stale with more recent Raspbian releases than Feb 2020. I've no means of testing right now, sadly.

@parsanoori
Copy link

Better to connect to the WiFi using CLI for the first time instead of plasma-nm, because otherwise it wouldn't auto connect at boot.

@kevin201
Copy link

Thank you, this worked perfectly on my Raspian 10 install until I did a recent "sudo apt upgrade", and lost the icon from the task bar. nm-applet is running but the icon doesn't show. Any suggestions would be much appreciated.

@truebit
Copy link

truebit commented Apr 25, 2021

remove sudo apt purge openresolv dhcpcd5, otherwise device would get two IP address in my RPi4 buster

@jmfloyd
Copy link

jmfloyd commented Apr 28, 2021

I have been trying to get nm working on the RPi 400. I now achieved nearly full success on buster.

Following the previous useful instructions still left my system with no networking. This is what I needed to the overcome that. Lots of interpretation from journalctl logs to track this down ...

  • Effectively do what is given previously
  • reinstall dhcpcd5 then disable and stop it with systemctl.
  • In /etc/NetworkManager/NetworkManager.conf
    dhcp = dhcpcd
  • Stop and disable wpa-supplicant with systemctl.
  • Stop and disable networking (the script based system) if you want a pure nm system - networking.service caused conflicts with nm on my system. Also need to remove or rename the interfaces.d folder because nm looks in it to possiblly manage old style configs. This can also be achieved by removing the updown plugin from nm. This all depends on whether you want a pure nm or a hybrid of nm and the old system of network config. I prefer to just use one.
  • restart NetworkManager with systemctl (enable and start)

I had last year got nm working well from the command line for a rpi-zero project that turned wifi on and off as required on a headless system. So I knew it could work! However being a headless system, I could just sudo all nmcli commands so many problems were not confronted.

My main problem on the 400 (using nm-applet) was the internal nm dhcp was stuffing things up, It was taking a long time to connect if at all and very intermittent. I am pretty sure that I have not left anything out.

The only problem now is that it now asks to confirm the password in a popup (with the password box filled in with the correct value) when I change the wifi connection from a user. This is with a password in the nmconnection config file. Not sure what is doing this at this moment. I have also modified the desktop polkit ...
/var/lib/polkit-1/localauthority/10-vendor.d/org.freedesktop.NetworkManager.pkla to allow user permissions.

This last problem is now fixed. Running xfce desktop, there is a desktop startup to activate the NM polkit. Doing this fixed asking for passwords. And add nm-applet into startup gets it the app in the desktop panel.

One other minor problem was to ensure that the country of use for wifi is declared in the /etc/default/crda file. In my case 5G freq were not recognized, some others caused connections to fail. It can cause strange behaviour not attributed to NM.

Cheers

@parsanoori
Copy link

Has anyone thought of reverse engineering Manjaro for Pi4 for this purpose ?

@benocd
Copy link

benocd commented Oct 27, 2021

I've been trying to connect raspberry pi's to corporate networks for the last 3 years without success until now. Thanks for this tutorial ;)

@sheminasalam
Copy link

Thanks for the post mate, I was having issues with my Home Assistant installation because of network manager, Now with your guide and using sudo nmtui to complete the configuration, things are normal

@benocd
Copy link

benocd commented Dec 14, 2021

In case you get a "Device not ready" message when trying to list the available WiFi networks, run this command:

sudo apt purge openresolv dhcpcd5

@Lightwel
Copy link

Hi - very pleased to have this guide, bit it fails for me at the bit where I’m supposed to get two applets in the Task bar. I only get the two crosses.

Have tried other widgets. “Manage networks’ gives me ‘wlan0 not connected’. nmcli confirms this.

Have reversed the steps for now…

Tks R

@jjsanderson
Copy link
Author

Thanks for the report, @Lightwel. I guess it's not a surprise that this guide is rotting a bit - it's a few years since I wrote it and lots has changed in whatever-Raspbian-is-called-these-days.

There are some helpful suggestions in the comments here (thanks, everyone!), and now I'm starting to return to my office I can just about construct a need to get a fresh Pi on Eduroam again. I'll try to update this guide if I do so, since - somewhat to my surprise - people seem to (a) find it, and (b) find it useful.

In the meantime I'll add a note to the guide.

@Lightwel
Copy link

Thanks and I look forward to it, as I continued to fiddle and have made things worse. Even though it contradicted your OP I added similar config to /etc/network/dhcpcd.conf to add wlan0 with hard-wired credentials. That allowed a wlan connection as confirmed by nmcli.

Now dhcpcd is blipping in and out and won't connect - I have an ether net cable connected and the applet flicks between traffic, wifi and no connection.

Have tried masking first dhcpcd and then NetworkManager, restarting, reloading and what I know of systemctl but no joy.

I do have a working installation of Network Manager on a Manjaro machine and am thinking of duplicating the files from there into the pi. I am going in faith that properly configuring wpa-supplicant at the back end will allow me to use NM and disable dhcpcd.

However, that could be a dead end.

Any advice on a temporary fix simply to restore dhcpcd to work will get me some breathing space. jmfloyd on 28 Apr 21 could be a start - do you think?

Best

R

@Lightwel
Copy link

Lightwel commented Jan 28, 2022 via email

@jjsanderson
Copy link
Author

@Lightwel wrote:

Any advice on a temporary fix simply to restore dhcpcd to work will get me some breathing space

Oh, I've not much of a clue, to be honest - lots of people commenting here seem to know far more than I've ever claimed to. I'm just the twit who wrote up something that (for a while) seemed to work.

What I would say is one of the advantages of Pis is that it's relatively easy to nuke them and start over. I used to spend a chunk of time setting them up in detail, but more recently I've opted to keep them as vanilla as I can precisely so that wiping the card is less painful. That's not much consolation for anyone looking to use a Pi 4 or 400 as a main desktop machine, but it's the only way guides like this stand a chance of working, really. Once people diverge from the starting point, fixing their setups involves somebody either getting lucky or actually knowing what they're doing. I'd describe my approach to network admin as 'informed luck.'

The only general advice I'd offer is to copy config files so you have a backup, prior to editing them. I might include that in the guide next time around, come to think…

@jmfloyd
Copy link

jmfloyd commented Jan 29, 2022

If I understand your problem with dhcpcd, it relates to making sure systemd is not controlling it.

Dont delete it. Use systemctl to stop dhcpcd and then disable it as well. That way systemctl is not controlling it, but it stays installed.

Hope this helps.

As I said in my post earlier, the basics are described well in the opening posts, but it left a mixed system running which caused problems for me. My post highlighted what I needed to do to convert to a pure network-manager system. It is now working on PiZeros and RpI4/400s.

Cheers

@Lightwel
Copy link

Gentlemen

Many thanks for your patient comments. NM is now up and running nicely, in preparation for my move to add KDE as an alternative desktop.

The only thing which gave me pause was finding the location of the /etc/networks/interfaces.d folder.

And in /etc/NetworkManager/NetworkManager.conf I added

dhcp=dhcpcd

in place of dhcp=internal. Which was probably obvious.

So I can confirm this worked with 2021-10-30-raspios-bullseye-arm64

Best

R

@Lightwel
Copy link

However, here I am back again.

NetworkManager seems to have broken dns - and I'm far from the only one to have problems according to the net, with many differene distros.

Does anyone have any direct experience of fixing this on the Pi running the Raspberry Pi 64 OS?

For the time being, I am mothballing the NM configuration.

Best

R

@Burt-Silverman
Copy link

Burt-Silverman commented Feb 5, 2022

Here is another thing that must be taken care of, although I don't know where the configuration change is stored, I just know it is crucial: https://askubuntu.com/questions/62166/siocsifflags-operation-not-possible-due-to-rf-kill. Actually, I had a bad upgrade from Buster to Bullseye. There are no problems after a fresh install of Bullseye.

@Yawgmoss
Copy link

Yawgmoss commented Feb 6, 2022

Hello,
I am an absolute Noob at Linux but was intrigued to get KDE up and running.. I first had success on RetroPie Buster by observing the systemctl --type service manifest to see that the networking.service was disabled. I enabled it and disabled dhcpcd.service. Nm tray begin scanning for wifi after a few moments. I then nuked the distro and reinstalled the bullseye 64 distro to try the same thing. It worked. However when I reboot, the settings in the manifest clear and I have to stop the dhcpcd.service service. again. Is there a way to write this to a conf file to keep the settings solid after rebooting? Good luck and thanks.

@joselucci
Copy link

Hello, this post was very useful. I was able to install the modem, I ask you, do you know any application or command for raspberry with which I can check the internet traffic of my network? because it is consuming 3gb per day. I only have rasp with teamviewer, and a camera, but I hardly even access it. Thanks a lot.

@scottw-finao
Copy link

scottw-finao commented Feb 9, 2022 via email

@joselucci
Copy link

#scottw-finao. Thanks a lot. I will try with that.

@kevin201
Copy link

I have been using vnStat and its php gui. If you only need a simple output, it does the job well.

https://humdi.net/vnstat/
https://www.tecmint.com/vnstat-php-frontend-for-monitoring-network-bandwidth/

https://imgur.com/Zad1dZR

@joselucci
Copy link

joselucci commented Feb 10, 2022 via email

@Klaaktu
Copy link

Klaaktu commented Apr 10, 2022

Is there a package to uninstall to remove the "Wired & Wireless Network" icon, besides the menu setting?
What I did:

  1. sudo apt purge dhcpcd5
  2. sudo apt install network-manager network-manager-gnome
  3. Reboot

@kevin201
Copy link

I seem to recall I just removed it from the task bar, using "Add/Remove Items".

@jjsanderson
Copy link
Author

@Klaaktu Sorry, missed your comment. I did this to remove the defunct menubar item:

You can remove the now-defunct default wifi widget by right-clicking the menubar and selecting 'Panel Settings -> Panel Applets'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment