There are a number of common requirements that require configuration. They are:
- Static IP address
- DNS settings
- Gateway Settings
- Wi-Fi Settings
Being Linux then there are several commands and configuration files that need to be used/edited.
However for most of us using a GUI is easier and PI provide one in the top right task bar.
Making changes using the GUI
To make changes you first need to select the Interface using the drop down box.
In the screen shot below I have configured the Wireless Interface to use a static IP address of 192.168.1.42 and the Ethernet Interface to have an IP address of 192.168.1.41
I’ve also enable the checkbox Automatically configure empty options and because of this the default Gateway (router) and the DNS server addresses will come from the DHCP server.
I have also disabled ipv6 on these interfaces.
Where are the GUI Changes Stored?
If you do some Goggling on configuring static IP addresses etc then you will come across many tutorials that take you through either editing the /etc/networking/interface file or /etc/dhcp/dhclient.conf file.
So the settings you change in the GUI are stored in one of those files is the logical conclusion that I came to.
However not so. If you go to these files they are either mainly empty or mainly commented out.
If you look for the static IP address you’ve just configured in the GUI and which works then it is nowhere to be found.
The answer is in the /etc/dhcpcd.conf file. Obvious really!
Well after spending hours searching online I’d finally found the answer. At least think I have.
If I look at my /etc/dhcpcd.conf file and right at the bottom I see these entries which correspond to my GUI entries.
If I do an ifconfig then this is what I see.
You will notice the Wi-fi has the correct address the Ethernet port doesn’t has I haven’t got a cable plugged into the port but the card is present as you see a MAC address.
You will also notice the IPv6 addresses which I disabled! I’ll work that out another day.
You may also find that it the /etc/dhcpcd.conf is empty if you haven’t made any network changes.
What a Happened to the /etc/networking/interface file
Well all my searching wasn’t in vain, as I stumbled across this article by Scargill which related his tribulations with configuring networking and included a very useful bit of history.
It seems that there are many different networking daemons that you can use on Linux and PI.
Over the years they have moved from the original daemon which used the /etc/networking/interface file to the now more common dhcpd.
But there are other like the wicd which is apparently a wrapper over dhcpd and I found running on my PI that I had upgraded from Stretch to Buster.
To find out what daemons you have running use the command:
In the screen shot below you can see that on my upgrade Pi (Stretch to Buster) both the dhcpcd and the wicd daemons are running.
It seems that most of the tutorials you find on the Internet are not longer valid as they were written for Debian Wheezy and all use the /etc/network/interfaces file.
The file you need to edit for Jessie,Stretch and Buster is the /etc/dhcpcd.conf file.
This is the file that the GUI changes
Dhclient and dhcpcd Daemons
Again most tutorials on the Internet have you changing the /etc/dhcp/dhclient.conf file and also show commands line
to release an IP address.
Doing this on PI has no effect as it uses dhcpcd daemon and not the dhclient daemon.
See this thread –dhclient vs dhcpcd
Implementing IP Address Changes
When you make a change to the IP address or any of the network settings they are not automatically applied you can apply then using the ipconfig config.
You use the ifconfig command to bring the network Interface down and then up and the change will take affect use:
sudo ifconfig wlan0 down #wi-fi sudo ifconfig eth0 down #Ethernet and sudo ifconfig wlan0 up #wi-fi sudo ifconfig eth0 up #Ethernet
Trouble Shooting Tips and Common Q&A
Unusual or Unwanted IP address
If for example you have an IP address of 192.168.1.41 and don’t know where this is coming from. The go to a command prompt and change to the /etc folder and type :
sudo grep 192.168.1.41 -r
I’ve edit the /etc/network/interface File What should I do?
It’s a good idea to change it back but it doesn’t seem to have any effect.
However you can switch back to using the interfaces file by disabling the dhcpcd and enabling the networking daemon
sudo systemctl disable dhcpcd sudo systemctl enable networking
I haven’t tried this
What is the Name of the GUI Used for Configuring Networking?
It is a lxpanel plugin called lxplug-network. See here
Cable Disconnects not Detected by Application
While running an MQTT client I noticed that when I unplugged the network cable the system detected it and displayed a network error however this was not passed to the application.
In addition when it was plugged back in the network was still showing as being down . The solution was to stop and start the interface using:
sudo ipconfig eth0 down
sudo ipconfig eth0 up
You should note that you need to disable it first or it doesn’t work.
There are many different networking options and the default options have changed considerably over the last few years.
Unfortunately most of the tutorial on the Internet relate to the old style networking using the /etc/networking/interfaces file but this is no long used on the raspberry Pi.
- Understanding DHCP on Home Networks
- 10 Useful Windows Networking Commands
- 10 Useful Linux (Raspberry Pi) Networking Commands
- Setting Up A Static IP Address on Windows 10