Configure profile to set WiFi preferences

IPCCASPER
New Contributor

We are having issues with our Macbooks not connecting to the nearest or most optimal wireless access point and/or WiFi network.

We've noticed that Macs "recommend" or prefer certain WiFi channels. As a result, they are not always connecting to to the closest WAP because the channel being made available from the nearest WAP isn't on the "recommended" channel list for that Macbook.

Or, the Mac will connect to the closest WAP, but will connect on the 2.4 GHz band rather than 5 GHz.

We'd like to set our Macbooks to prefer certain channels in the 5 GHz range. We've noticed that our Macbooks will recommend some, but not all of the channels we are using, so we'd like to make sure the Macs recommend all of them.

We'd also like to set it so Macs will prefer the 5 GHz network over the 2.4 Ghz band, and we'd like to increase the "aggressiveness," so Macs will quickly switch between WAPs when the Macbook is being moved.

I'm not sure how to configure a policy to push out these settings, or whether this is even possible.

5 REPLIES 5

CapU
Contributor III

You may have to look at how the Wifi access points are setup. Some may need to be turned down or only allow 5GHZ clients.

jjones
Contributor II

There is a command that OSX has that is buried in /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

Using airport prefs will show you a small list of settings currently set for wifi. You might check with using this command:

airport prefs joinMode=Strongest
I haven't tested it out so be aware that it could inadvertently cause more issues, but it could be what you are looking for.

joshua
New Contributor

This is a script we use to set the preference on our network. I found this in the forums here, just dont remember where. So credit is due to someone else. We just modified a few of the parameters.

# /bin/bash

#This script is made to change the priority of the populated SSID to 0 (Top of list)
#It has been tested and does not de-auth the user if they are currently on the SSID to be changed (If the SSID password remains in the keychain)
#This has been tested on 10.10 and 10.11

#Sets arguements for script
#Disabled NetworkDevice as NetworkPort will auto-detect WiFi port location
    Priority=$4
    PreferredNetwork=$5
    WirelessSecurity=$6
    RemoveNetworkAlso=$7
#Running RemoveNetworkOnly populated will not run other options
    RemoveNetworkOnly=$8
#Setting argument $9 to anything will trigger this to be run (i.e. asdfasdf) Will run with RemoveNetworkOnly
    ShowPreferred=$9
#Sets arguement to check for port location of wifi, nulls need of NetworkDevice.
    NetworkPort=`/usr/sbin/networksetup -listallhardwareports | grep -A 1 Wi-Fi | grep Device | cut -d' ' -f2`

#As stated above, if the RemoveNetworkOnly field is populated the script will only run the very last command.
if [ -z $RemoveNetworkOnly ]; then
#Checks if all arguements have been entered, will exit out with statement if no settings have been set.
    if [ -z $NetworkPort ]; then
        echo "WiFi Port not detected, please ensure system has WiFi capabilities"
        exit 1
    else
            if [ -z $PreferredNetwork ]; then
                echo "Please set the Preferred Network SSID"
                exit 1
            else
                    if [ -z $WirelessSecurity ]; then
                        echo "Please set the Wireless Security Type" 
                        exit 1
                    else        
                        #Echos all arguements
                        echo "Network Device is $NetworkPort" 
                        echo "Preferred Network SSID is $PreferredNetwork" 
                        echo "Wireless Security Type is $WirelessSecurity" 

                        #Changes Priority of SSID to 0
                        networksetup -removepreferredwirelessnetwork "$NetworkPort" "$PreferredNetwork"
                        networksetup -addpreferredwirelessnetworkatindex "$NetworkPort" "$PreferredNetwork" "$Priority" "$WirelessSecurity"
                        echo "Priority changed"

                            #If RemoveNetworkAlso is populated it will run otherwise the script will close
                            if [ -z $RemoveNetworkAlso ]; then
                                networksetup -removepreferredwirelessnetwork "$NetworkPort" "$RemoveNetworkAlso"
                            else
                                echo "SSID $RemoveNetworkAlso Removed"

                            fi
                    fi
            fi
    fi
else
    if [ -z $NetworkPort ]; then
        echo "WiFi Port not detected, please ensure system has WiFi capabilities"
        exit 1
    else
        if [ -z $RemoveNetworkOnly ]; then
            echo "Unknown error, check to make sure script has not been edited"
            exit 1
        else
            networksetup -removepreferredwirelessnetwork "$NetworkPort" "$RemoveNetworkOnly"
            echo "SSID Removed"
        fi
    fi
fi

#If arguement is populated it will show preferred list *Warning can be a large list*
#Do not rely fully on this as it can have false reporting, having a sleep time has not helped. 
if [ -z $ShowPreferred ]; then
    echo Done
else
    networksetup -listpreferredwirelessnetworks "$NetworkPort"
fi

exit 0

jjones
Contributor II

@joshua That's the script I made btw lol, but how his question is, I do not believe the script will help him ultimately with the 2.4/5Ghz issue and the aggressive setting.

IPCCASPER
New Contributor

We've checked the WAPs and their settings, that's how we discovered this. PCs don't have this issue with only using some channels when connecting to our WiFi; only the Mac clients. We've got the Macs set up to automatically log in to our WiFi with the logged on user's credentials when the WiFi NIC is enabled.

We plan on phasing out the 2.4 GHz band soon, but until then we'd like Macs to prefer 5 GHz if that's possible.

I'd read the man page on the airport command, but I seem to have missed that particular option. I'll check that out.

Thanks for the feedback.