Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing Network Manager on Raspbian 2020-02-05

Installing Network Manager on Raspbian 2020-02-05

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.

@maroc81

This comment has been minimized.

Copy link

@maroc81 maroc81 commented Jun 12, 2020

Thanks for this. I was trying to configure interfaces from a headless system using nmcli and couldn't get wifi going. Disabling dhcpcd and restarting network manager did the trick for me.

@scottw-finao

This comment has been minimized.

Copy link

@scottw-finao scottw-finao commented Jul 1, 2020

any suggestions on configuring a wwan0 on usb? I have a netgear beam (330u) which works just fine with a nmcli configuration on ubuntu. It seems to work fine on raspbian (the interface comes up, route is created, modem says it's connected) but you can't seem to get any traffic to flow over the wwan0 interface with ping or traceroute. (ping does nothing until you ^C and traceroute just returns * * * until it gives up)
Any idea why it would create the interface, bring it up, but then not allow traffic to flow over it?

@jjsanderson

This comment has been minimized.

Copy link
Owner Author

@jjsanderson jjsanderson commented Jul 1, 2020

@scottw-finao Not a clue, I'm afraid. I'm really not a networking guru, I just managed to puzzle out this bit and wrote it up for my own reference (and in the hopes that it might help others). These links look to be in the right sort of territory (found while trying to work out what a Netgear Beam is), but doubtless you've already seen them.

(for anyone arriving via Google, there's the start of a more detailed thread of the above query at the Raspberry Pi Forum ).

@scottw-finao

This comment has been minimized.

Copy link

@scottw-finao scottw-finao commented Jul 1, 2020

OK, thanks - you still provided more helpful info than I've gotten elsewhere (which amounts to pomposity and snark). I got a few ideas to try from the links you'd listed in the post that brought me here. (which I believe are the same as those you just linked)

Over on the raspbian forum, I got "nmcli isn't the default way to do it" with no help on whatever the 'default' way to do something that isn't documented anywhere may be. lol

@scottw-finao

This comment has been minimized.

Copy link

@scottw-finao scottw-finao commented Jul 1, 2020

In the meantime, I noticed that hologram has a few new features. I picked up an omega2 openwrt based linux sbc with a pre-order on their hologram cellular shield a few years back to try for this same project. When I tried it the omega2 was a bit too limited and the hologram content cloud-walled which both didn't work for what I'm trying to do.
But checking their site again for kicks I found they offer a new program that allows tunnelling selected ports around the cloudwall, and they are also selling a new mini, USB based LTE board to work with their service which they are marketing at raspberry pi users. It may work better than the Beam in that it's smaller and uses less power, and I can tie it into my existing set-up which I configured with the ability to turn the USB ports and their power (individually) off at night or when the batteries are low.
I'm hoping that it may even work with the AT&T hotspot sim, but even if it doesn't, I can do what I need using their port tunnelling.

@jjsanderson

This comment has been minimized.

Copy link
Owner Author

@jjsanderson jjsanderson commented Jul 1, 2020

🤦 Ah, the Raspberry Pi forums… you'll never find a more wretched hive of scum and villainy…

Crazy thought: if the device has worked for you in Ubuntu, have you tried the Pi packaging of Ubuntu MATE? That might cause other issues for you, but if it works in Ubuntu you'd have at least narrowed the search down.

@scottw-finao

This comment has been minimized.

Copy link

@scottw-finao scottw-finao commented Jul 1, 2020

Last year I couldn't even get nmcli to work at all. They've changed something between then and now. At that time I tried an ubuntu rpi dist (with different but still not functional results). If I can't get anywhere tonight, burning another ubuntu was one of the other things I was going to try.
On an unrelated note, I also have a banana pi running a custom built raspbian - but while it loads all the kernel mods, I don't get a wwan0. Can't figure that one out either.

@BorisDess

This comment has been minimized.

Copy link

@BorisDess BorisDess commented Sep 4, 2020

Thanks for the tutorial ! 👍

@kmhcarmona

This comment has been minimized.

Copy link

@kmhcarmona kmhcarmona commented Sep 17, 2020

@jjsanderson I made a GitHub account specifically to thank you. So thank you! I was getting wildly frustrated with the constant Wi-Fi drop on my RPi 4. This solved it, out of tens of suggestions from other forums (or omg fora?). Really appreciate it!

@tcadd

This comment has been minimized.

Copy link

@tcadd tcadd commented Nov 6, 2020

Thanks for this, worked really well and very clear instructions!

@sdaitzman

This comment has been minimized.

Copy link

@sdaitzman sdaitzman commented Nov 9, 2020

Thank you for providing this information! Unfortunately, I'm still seeing a "device not ready" under WiFi networks in the applet. Has anyone encountered and fixed that?

EDIT: of course, as soon as I commented this I found the solution. I ran $ sudo apt purge openresolv dhcpcd5 and that fixed everything! Thank you for this amazing documentation ☺️

@jjsanderson

This comment has been minimized.

Copy link
Owner Author

@jjsanderson jjsanderson commented Nov 24, 2020

Ah, interesting @sdaitzman - thanks for documenting that step. Something like that had been required in earlier versions of Raspbian, but I hadn't needed it when I wrote this gist in February. There have been several Raspbian releases since, so I wonder if something has reverted? I don't currently have access to the building with corporate wifi to test against, but I'll update the gist as and when I can test.

@tcadd, @kmhcarmona, @BorisDess - thanks too for your kind words, I'm glad the gist was helpful.

@StephenE

This comment has been minimized.

Copy link

@StephenE StephenE commented Dec 6, 2020

Thanks for the guide, it was very helpful. I ran into an issue after following it where my MAC address would change after reboot. I found the fix at https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=196348&start=25#p1524581

If you have Network-Manager installed:

To disable the MAC address randomization create the file
/etc/NetworkManager/conf.d/100-disable-wifi-mac-randomization.conf
with the content

[connection]
wifi.mac-address-randomization=1

[device]
wifi.scan-rand-mac-address=no

This worked for me

@jjsanderson

This comment has been minimized.

Copy link
Owner Author

@jjsanderson jjsanderson commented Dec 7, 2020

Thanks for the addition, @StephenE. I haven't run into that issue, though I've also not been looking for it. Useful to have the configuration documented here; people seem to be finding this gist with increasing frequency.

@thoschworks

This comment has been minimized.

Copy link

@thoschworks thoschworks commented Dec 21, 2020

@jjsanderson

Thanks for this info.

🤦 Ah, the Raspberry Pi forums… you'll never find a more wretched hive of scum and villainy…

Crazy thought: if the device has worked for you in Ubuntu, have you tried the Pi packaging of Ubuntu MATE? That might cause other issues for you, but if it works in Ubuntu you'd have at least narrowed the search down.

On my Intel desktop Ubuntu (20.04, Mate) does not use dhcpcd5 (it's not installed), which seems to be the trouble maker.

@gokayeren

This comment has been minimized.

Copy link

@gokayeren gokayeren commented Dec 23, 2020

Hi, I'am using local-link with eth0 so when I follow your tutorial everyting ok but I can't go internet. I add this code denyinterfaces eth0 to /etc/dhcpcd.conf . I have internet now. Thanks for tutorial.

@bilal-61

This comment has been minimized.

Copy link

@bilal-61 bilal-61 commented Dec 30, 2020

First off, thank you very much for providing this guide. After hours of research and setting up Raspbian over again I found this.

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.

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?

@thoschworks

This comment has been minimized.

Copy link

@thoschworks thoschworks commented Dec 30, 2020

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

This comment has been minimized.

Copy link

@bilal-61 bilal-61 commented Dec 30, 2020

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

This comment has been minimized.

Copy link

@krisnand krisnand commented Jan 13, 2021

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

This comment has been minimized.

Copy link
Owner Author

@jjsanderson jjsanderson commented Jan 13, 2021

@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

This comment has been minimized.

Copy link

@parsanoori parsanoori commented Mar 28, 2021

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

This comment has been minimized.

Copy link

@kevin201 kevin201 commented Mar 28, 2021

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

This comment has been minimized.

Copy link

@truebit truebit commented Apr 25, 2021

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

@jmfloyd

This comment has been minimized.

Copy link

@jmfloyd 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

This comment has been minimized.

Copy link

@parsanoori parsanoori commented Apr 28, 2021

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

@benocd

This comment has been minimized.

Copy link

@benocd benocd commented Oct 27, 2021

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

@sheminasalam

This comment has been minimized.

Copy link

@sheminasalam sheminasalam commented Nov 19, 2021

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

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