I am using Ubuntu 14.04 server version on a turtle bot which is moving around. It is connected to my network with 4 APs around. My aim is to switch between APs when the turtle bot moves around. Currently it will keeps holding on to the current AP until the signal level is super bad before it switches. I wrote a script which constantly gets the strongest AP MAC address. I was wondering whether there is a way I can force connect to an APs MAC address. A little bit of googling and all I found was the below commands which didn't work when I tried it.

iwconfig wlan0 ap MACAddress  
ip link set wlan0 down  
ip link set wlan0 up  

I also found nmcli d wifi connect password iface bssid MACAddress which did help me to connect but I would like not to use password and username in the command, but use the setting in /etc/network/interfaces.Is there any other methods I can use to achieve what I need? I'm running Ubuntu 14.04.

1 Answer 1


You might want to look into and install wpasupplicant

How To: set up wpa_supplicant roaming mode and automatically start at boot

Specifically for the MAC address part, from the Gentoo wiki https://wiki.gentoo.org/wiki/Wpa_supplicant

Using bssid to specify which access point it should connect to using its MAC address, in case there are repeaters in place. Remember to use wpa_passphrase [passphrase] to generate the psk

FILE /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

        group=CCMP TKIP
        pairwise=CCMP TKIP
  • Thanks for your reply, but my bot is running around and therefore the mac address keeps changing. Since we are hard coding mac address in wpa_supplicant.conf file, I cant use it for my purpose Feb 27, 2017 at 9:44

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.