3

I am using a Pi2 with Wifi USB Wifi Adapter. Every time I boot, I have to connect to the wifi manually by providing the password. Is there any way Pi2 can automatically connect to the wifi on boot?

When I boot up, only Wifi Dongle is connected, not the ethernet cable.

My settings are as follows.

/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.40.201
netmask 255.255.255.0
network 192.168.40.0
broadcast 192.168.40.255
gateway 192.168.40.1
dns-nameservers 4.2.2.2

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="Cisco09589"
psk="password"
key_mgmt=WPA-PSK
}

OS and Kernel version

pi@raspberrypi ~ $ cat /proc/version Linux version 4.1.19-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #858 SMP Tue Mar 15 15:56:00 GMT 2016

pi@raspberrypi ~ $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie

pi@raspberrypi ~ $ cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

5
  • Unless you are using a year old Raspbian this won't work. See How do I set up networking/WiFi/Static IP If you still have problems you need to describe your network.
    – Milliways
    May 11, 2016 at 9:28
  • I tried that, However it's still not working. I have added the OS and kernel information in the question. May 11, 2016 at 9:44
  • But what is the configuration of your network?
    – Milliways
    May 11, 2016 at 10:34
  • It's a wifi network with given settings. It's DHCP type. May 11, 2016 at 10:41
  • please show your "iwconfig" after boot! May 12, 2016 at 15:03

3 Answers 3

4

I had the same issue when I once configured the wifi through the preinstalled GUI. There was no other chance than reinstall raspian and make the whole configuration with /etc/network/interfaces.

I would recommend not using the /etc/wpa_supplicant/wpa_supplicant.conf but instead put your wifi password and name into your configuration directly.

This would be my configuration with a static IP address to easily connect with your PI via ssh:

auto lo
iface lo inet loopback

iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
    address 192.168.0.198
    netmask 255.255.255.0
    network 192.168.0.1
    broadcast 192.168.1.255
    gateway 192.168.0.1
    wpa-ssid "WIFINAME"
    wpa-psk "WIFIPASSWD"

Don't forget to restart your wifi, after you made your changes!

2

Your current wlan0 configuration requires manual IP setup (like for eth0 in this file or via ifconfig like command). I hope you are using DHCP, so replace string "iface wlan0 inet manual" with "iface wlan0 inet dhcp".

0
2

I tried half a dozen tutorials using wpa-supplicant, iw and /etc/network/interfaces. But they all did not work for me. Probably because they did not describe at all what they were doing. So I always ran into a point where it did not work and there was no error message nor any way to find out the source of the problem.

Finally I simply tried installing the default network-manager. Which happens to be the gnome-network-manager but without any GUI part.

So in short, the solution is:

sudo apt --no-install-recommends install network-manager
nmcli connection add ifname wlan0 type wifi ssid <Your-SSID>
nmcli connection edit wifi-wlan0

While editing the config file you have to set WPA-PSK and the plain text password:

nmcli> goto wifi
nmcli 802-11-wireless> set mode infrastructure 
nmcli 802-11-wireless> back 
nmcli> goto wifi-sec 
nmcli 802-11-wireless-security> set key-mgmt wpa-psk 
nmcli 802-11-wireless-security> set psk <your-plain-text-password>
nmcli 802-11-wireless-security> save 
nmcli 802-11-wireless-security> quit 

After that reboot and enjoy! The network-manager will take care of everything!

If it complains about permission, the recommended way seems to be to modify/overwrite the policykit rules from /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy. I gave up on that and used sudo instead. If anybody knows a clean way to do it, tell us please!

Here is a very good guide, but it's in german: https://wiki.ubuntuusers.de/NetworkManager/NetworkManager_ohne_GUI/

1
  • this is the only working solution for me, thanks Oct 7, 2021 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.