Powershell
Posts: 44
Joined: Fri Apr 08, 2016 10:24 am

Fast switching of WIFI networks

Fri Dec 30, 2016 3:27 pm

Hi guys and happy new year!

I travel alot and I always take my Pi 3 with me as a headless server.

To use public hotspots, I need a solution to quickly add SSID and PSK of any new network.

Would it be correct if I somehow do the following:

I put a copy of "/etc/network/interfaces" to a FAT partition of Pi's sdcard.
Take the card out and edit it on my laptop.
When booting, a shell command will "cp -f /boot/interfaces /etc/network" (overwrite)

Will it do, or is there more elegant method? Thanks!

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Fast switching of WIFI networks

Fri Dec 30, 2016 10:50 pm

Put all network defs in your wpa_supplicant.conf file and your system will automatically connect to the network in range.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

jbudd
Posts: 1446
Joined: Mon Dec 16, 2013 10:23 am

Re: Fast switching of WIFI networks

Sat Dec 31, 2016 12:20 am

With the current version of Raspbian Jessie you should be managing wifi credentials in /etc/wpa_supplicant/wpa_supplicant.conf.

On bootup it looks for a wpa_supplicant.conf file in /boot (which is writable on your PC). If it finds one, it copies it to /etc/wpa_supplicant/ and deletes the original.

This gives a nice easy way to input the details of new networks:

sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /boot/supplicant.txt

Now on your PC add the new network to the file "supplicant.txt" and copy it as wpa_supplicant.conf
A basic wifi stanza might look like this

Code: Select all

network={
        ssid="MuseuDoAmanha"
        psk="CidadeMaravilhosa"
}
but there are many other parameters available for different network authorisation methods

When you boot the Pi, with a little luck it will connect.

Powershell
Posts: 44
Joined: Fri Apr 08, 2016 10:24 am

Re: Fast switching of WIFI networks

Wed Jan 04, 2017 7:12 am

Thanks! That makes sense!

At what stage it is better to invoke this?

Return to “Troubleshooting”