Ubuntu Core WiFi Configuration Issue – How to Resolve

ip addressubuntu-corewireless

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:

  1. Once logged in to the Pi, I executed sudo classic
  2. 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
    
  3. Saved the file and I execute sudo ifup wlan0

  4. At this point when I execute ifconfig, the IP Address and other settings are visible under wlan0. Punched the air in celebration.

  5. 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:

enter image description here

Best Answer

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:

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopbak

auto wlan0
iface wlan0 inet static
address 192.168.0.30
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1 8.8.8.8
wpa-ssid <your_router>
wpa-psk <ypur_secret_key>

Restart the interface:

sudo ifdown wlan0 && sudo ifup -v wlan0

Check:

ping -c3 www.ubuntu.com

You should be all set.

Related Question