RPI4 Network Lesson

I learned something new last week-ending Aug 10, 2019)…. and now MORE…

I’ve set up countless Raspberry Pi 2 and 3 SBCs over time, usually headless and using the file /etc/dhcpcd.conf to set up a static IP address, It works every time. Or WORKED every time. Read on for some hopefully useful info…

Raspberry Pi 4 upgraded from a working Stretch to BusterWhen I got my new RPI4, I upgraded all my older systems to BUSTER, not one of the easiest things to do and indeed not recommended on the RPI-forums. (Use a clean installation, they say. GREAT unless you happen to have years’ worth of complex, only partly documented code on your RPI2 or 3.

Well, I did upgrade, the change is all documented on the blog – and of course when it came to setting a static IP address I never thought twice about it. I used my Buster-upgraded installation several times on the RPI4 without issue.

NetworkThat is until recently when, frustrated with a few packages of little relevance being “held back” by “sudo apt-get upgrade” or as I now call it “sudo apt upgrade”.

I discovered that if you use “sudo apt dist-upgrade” you get all the packages available. Following that by “sudo apt autoclean” gets rid of any old versions lying around and you’re all set.

I checked out two of my RPI-3 boards with this thoroughly up to date setup and all was well until the weekend when I tried this on the RPI-4 – no IP address. I don’t use the graphical desktop and hence could not even see if the board was working.

Reluctantly I fitted a screen, keyboard and mouse to the RPi-4 – and as user PI at a command prompt I could then play with the board (like I have nothing better to do). But nothing I did would bring up the Ethernet connection. I even checked /etc/network/interfaces as recommended by one chap on the web… No.

Then my friend Antonio reminded me that “the script” has a couple of commented out lines that allow for permanent setting of graphical mode and vice-versa. I put the RPi-4 into graphical mode and reset. That helped but still no Ethernet. In the setup on the graphical desktop you can set a fixed IP address. I tried that – that seemed to work – but setting up by the desktop is not ideal for me.

The dist-upgrade seems to have enabled WICD – despite (according to Steve Lenehan in here) it being no longer supported. That being the case I was happy to stick with dhcpcd.conf – I promptly disabled then totally removed WICD. Antonio (Mr Shark concurs that WICD is now old hat and is not supported.

Solved:

A file called “/etc/wicd/wired-settings.conf” – that exists in my older images but with  IP etc set to “none” – Antonio thought that it might override “/etc/dhcpcd.conf” – well, it took over from dhcpcd.conf  – I got rid of it when I removed the /etc/wicd folder and all was well on my new PI4 except that…. in /etc/dhcpcd.conf, I gave the Pi the fixed address of 192.168.1.30 – that worked a treat, but sadly so did 192.168.1.20 – an address I could find no reference to in any file in /etc/ – yet there it was… I could SSH into either address.

According to the graphical desktop I’ve disabled WIFI so that wasn’t it. Turns out (thank you Antonio for spotting this) that while my manual update of /etc/dhcpcd.conf was of course working and setting up the static address as it always has, with the combination of SPI4 and Buster somehow, nmtui (Network Manager Text User Interface) had silently added in the second address (192.168.1.20) on DHCP. For now I’ve disabled Network Manager but it looks like the real answer, as nmtui has been around for a long time, would seem to be to comment out any manual mods to /etc/dhcpcd.conf and set a static address (192.168.1.30) in nmtui.

That didn’t work well at least using an eth0 entry. What DID work well was to put a manual address into /etc/dhcpcd.conf as has always worked and killing Network Manager (once only) like this:

sudo systemctl disable network-manager

sudo apt remove –purge network-manager

sudo rm –rf /etc/network-manager

I did this remotely using Mobaxterm on my PC, after which a reboot and all was wonderful.

Ok, as an alternative this seems to work and can be done from SSH – i.e. remotely.

With Network Manager un-installed – and running on dhcp.conf, I installed Network Manager (sudo apt install network-manager) – I used nmtui to set up eth0 with a static 192.168.1.30 address…. and then:

sudo systemctl disable dhcpd.service

sudo reboot

That STILL left me with 30 and 20 (keep up) so THIS time I deleted eth0, left “Wired Connection 1” in but made it static 192.168.1.30, then booted. All works a treat, no more 192.168.1.20

Unbelievable. So now I have Buster on RPI4, upgraded from Stretch without starting from scratch and it seems, all working well.

Incidentally, those two lines selecting command line or desktop, commented out… below..

# you may want to use these on a Pi or elsewhere to force either a graphical or command line environment
#sudo systemctl set-default multi-user.target
#sudo systemctl set-default graphical.target

 

Ways of changing network settings

According to Mr Shark:

EducationThere are at least 5 different methods of setting up networking in Linux, each has its own config file, each can manage static AND dynamic ip, each is independent and can cause the collisions we’ve seen above… Let’s try to clarify, I’ll just list them with basic details, and give proper online GOOD documentation… a RTFM hasn’t ever harmed anyone…

Choose ONE of these, and be sure the others are disabled, not with just lines commented out in their config file… we had issues because of commenting out lines in /etc/dhcpcd.conf file while using Network Manager… but commenting out lines in that file will just revert its daemon to its standard behaviour, which is requesting IPs via dhcp… so the double ones, fixed by nmtui, and dynamic by dhcpcd…

In double quotes the service/daemon name, which you should enable/disable and/or start/stop via the usual “sudo systemctl enable|disable|start|stop|status SERVICENAME” command

1) the good old “networking” service
it’s configured via the /etc/network/interfaces config file, info: https://wiki.debian.org/NetworkConfiguration

2) the “wicd” service, which was installed by previous (to Buster) Raspbian editions if you used the GUI version, and deprecated by Buster (you end up having it only if you upgrade from previous editions and did not follow full instructions on Raspberry site to remove it and other stuff after upgrading…)
it’s configured via the /etc/wicd/*.conf config folder/files, info: https://wiki.archlinux.org/index.php/Wicd

3) the usual “dhcpcd” Raspbian suggested method
it’s configured via the /etc/dhcpcd.conf file, info: https://wiki.archlinux.org/index.php/Dhcpcd

4) the almost standard method in every modern distribution, “network-manager”
it is configured via various tools, in console you can use “sudo nmtui” (Network Manager Text User Interface), very easy to do, info: https://wiki.archlinux.org/index.php/NetworkManager

5) the newer method, the “netplan” way
it uses the format which you’ll find in MANY other services today (Docker and Home Assistant in primis), which is the YAML file format, that implies you format and indent the file in a PRECISE spaced style, otherwise you’ll get errors…
managed via the /etc/netplan/* files, info: https://help.ubuntu.com/lts/serverguide/network-configuration.html

We hope this is clear. Now, and if you want more details, as above, RTFM

Facebooktwitterpinterestlinkedin

5 thoughts on “RPI4 Network Lesson

  1. a huge thanks for putting this in writing here Pete, and sorry to read you learned about it the hard way. at least it will save some folks the headaches.
    i consider myself an experienced unix/linux admin, but this is also new to me.

    i do read release updates etc, but it gets harder to keep up with the swelling releases/versions

    so a big thank you sir!

    i prefer though to let my ubiquity router handle the dhcp fixed ip’s, easier to maintain a single list, but that is just personal preference i suppose

  2. Thanks Peter, for slogging it out for us all. Had a similar problem with Octoprint a while ago. They had mored where to put the static IP address. Update need uniformly across the linux spectrum.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.