My static IP address settings are being wiped out each time I reboot my Raspberry Pi.
I just installed Ubuntu Core on a Raspberry Pi 3 but I have struggled to establish a wifi static IP address.
The following are the steps I went through:
- Once logged in to the Pi, I executed sudo classic
Executed sudo nano /etc/network/interfaces and added the following content:
source-directory /etc/network/interfaces.d
auto wlan0 iface wlan0 inet static address 192.168.0.30 broadcast 192.168.0.255 netmask 255.255.255.0 gateway 192.168.0.1
Saved the file and I execute sudo ifup wlan0
At this point when I execute ifconfig, the IP Address and other settings are visible under wlan0. Punched the air in celebration.
I execute exit to return to snap and then I execute sudo reboot to restart the Pi. I also immediately remote the ethernet cable from the Pi so wifi can handle the Internet requirements.
This is where my problems begin.
I check my routers IP address listings and my static IP is not included.
I log back into my Pi and execute ifconfig again the IP Address and other settings for wlan0 are no longer present.
The wifi ID and password are contained in the /etc/wpa_supplicant/wpa_supplicant.conf file and below are the contents:
network={
ssid="SKY8317B"
psk="TRUMBOX"
key_mgmt=WPA-PSK
}
I would really appreciate some help in fixing this issue where my static IP address fails to persist.
UPDATE#1: The following is verbose debug output based on the very helpful input of @chili555
sudo ifdown wlan0 && sudo ifup -v wlan0
ifdown: interface wlan0 not configured
Reading directory /etc/network/interfaces.d
Configuring interface wlan0=wlan0 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/bridge
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
wpa_supplicant: wpa-driver nl80211,wext (default)
wpa_supplicant: /sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wlan0.pid -i wlan0 -D nl80211,wext -C /run/wpa_supplicant
Starting /sbin/wpa_supplicant...
wpa_supplicant: creating sendsigs omission pidfile: /run/sendsigs.omit.d/wpasupplicant.wpa_supplicant.wlan0.pid
wpa_supplicant: ctrl_interface socket located at /run/wpa_supplicant/wlan0
wpa_supplicant: configuring network block -- 0
wpa_supplicant: wpa-ssid "SKY8317B" -- OK
wpa_supplicant: wpa-psk ***** -- OK
wpa_supplicant: enabling network block 0 -- OK
/bin/ip addr add 192.168.0.30/255.255.255.0 broadcast 192.168.0.255 dev wlan0 label wlan0
/bin/ip link set dev wlan0 up
/bin/ip route add default via 192.168.0.1 dev wlan0 onlink
/bin/run-parts --exit-on-error --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/000resolvconf
run-parts: executing /etc/network/if-up.d/openssh-server
run-parts: executing /etc/network/if-up.d/ubuntu-fan
run-parts: executing /etc/network/if-up.d/upstart
run-parts: executing /etc/network/if-up.d/wpasupplicant
UPDATE#2:
Result of executing => lsb_release -d:
Description: Ubuntu 16.04.4 LTS
Result of executing => cat /etc/netplan/*:
network:
version: 2
ethernets:
all-en:
match:
name: "en*"
dhcp4: true
all-eth:
match:
name: "eth*"
dhcp4: true
UPDATE#3:
On my travels across the Internet I came across a post somewhere which said updates manually made to the /etc directory will not persist. I opted not to believe that at the time but I just found the sudo console-conf command which seems to be the built in solution.
Using that command, you can provide the wifi SSID and password. Resetting the Pi and logging back in shows that the settings I provided are still in place.
Another setting to be provided is static IPv4 data but I don't know how to set that info i:e subnet in CIDR format. Below is a screen shot of my attempted settings:
You have failed to specify the SSID, normally a router, that you wish to connect to, you haven’t provided the WPA2 password, you haven’t provided DNS nameservers and, finally, the broadcast declaration is unnecessary. I suggest that you amend the file to:
Restart the interface:
Check:
You should be all set.
This took a long while to figure out.
I can only guess Ubuntu Core does things differently from the previous versions of Ubuntu and Raspbian. Otherwise editing the /etc/network/interfaces file as I did in my original post should have worked.
I want to give my sincere thanks to chili555 for all his efforts to help me with this problem.
Solution:
Ubuntu Core operates the SNAP package manager. I assume it is SNAP which is responsible for the sudo console-conf command. Upon execution, you should see something like the following:
Press enter on the highlighted OK button and you will have access to the network connections area:
In this area, as in all others under console-conf, you use the arrow keys to navigate to sections of interest. The wlan0, wireles card #1, is of interest to me so I have it highlighted in the screen shot. Then, I press enter.
Notice the Configure WIFI settings menu. When you hit enter with that menu highlighted, the resulting interface is where you set your wifi SSID and password.
Same applies for my attempts to set a static IP address. Just hit the down arrow once to land on the Use a static IPv4 configuration and hit enter to provide the IP details you want to make your Pi wifi accessible.
The subnet mask gave me a lot of trouble. I'm not network engineer and I assumed it was supposed to be 255.255.255.0/?? but the menu complained with error messages. Below is the data that worked ( I guessed upon the correct subnet mask ):
I hope people find this time saving and helpful.