I have a Linux server running on a laptop.

I would like it to auto-connect to any open WiFi network automatically. (Without knowing the SSID beforehand)

It's for a remote server deployment of ZoneMinder @ a cabin on a large property. If the burglars are REALLY smart they could get on the WiFi and hack the ZoneMinder server, but I highly doubt it and my "client" aka my parents have the WiFi set to Open.

  • I'm curious about the use case. Why would your parents set the WiFI to open? Wouldn't they be more secure (and better off) if it was secured? What about somebody else using their network for nefarious purposes? (Had you said ZoneMinder in traveling motorhome parked in different campgrounds every night, that would have made more sense to me...) – zipzit Jun 4 '17 at 16:10
  • Large remote property... Its like a mile from the road to the home. They are not that concerned. I know its a crazy thought, but some people dont even lock there door. Its nice to not have to worries when you live in a safe place. – FreeSoftwareServers Feb 2 '18 at 19:31

To have your computer search and connect to ANY Open Wifi modifiy the following two files:

*This was tested on Ubuntu 14.04 x64 Server


##Wireless NIC
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface open_wifi inet dhcp


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


Now bring interface down/up and check status.

sudo ifconfig wlan0 down && sudo ifconfig wlan0 up && sudo wpa_cli -i wlan0 status

Look for



use both ifconfig/ping

IF ifconfig show's no private IP and ping should fail

dhclient wlan0

try again and should show privateIP and ping should succeed.

To manually connect via config for debugging use this:

wpa_supplicant -d -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext

-d = debug/verbose -dd == super verbose

-D = driver

wext = "catch-all driver"

I tested with phone via hotspot which is PERFECT because it tells you when a client connects. I also turned off HotSpot and it reconnected when it turned back on! Only down side is if you are in a populated area, like my testing environment, it connected to "Xfinity-Wifi" which is open and then I had to reboot then it seemed to go with my hotspot due to it being a stronger signal. But once it was on XFinity it would not leave it unless I specified the Open Network SSID inside of the wpa_supplicant.conf OR rebooted.

  • More detailed blog about multiple SSID's and Eth0 Problems with Static IP Solutions @ my blog post here – FreeSoftwareServers Dec 22 '15 at 6:22
  • You should provide some more sources on how you came by your answer. When there is more than one open wifi connection within range, how do you specify the one you prefer? – vfclists Feb 2 '18 at 15:06
  • You cant it connects to strongest wifi i think automatically. Read description for question. Sources are my own testing and trial and error. – FreeSoftwareServers Feb 2 '18 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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