Wrong country code set on my Mac's Airport WiFi interface is blocking me from using channels 12 and 13
Hey guys,
After searching the forums, it turns out that the MacBook's Airport WiFi interface (under OSX Lion) upon turning on is picking up the first WiFi signal in the area and setting the interface's country code to the one of that router's signal.
I live at the moment in the Netherlands and it's quite a busy country in the cities especially when it comes to WiFi networking. In my house the best channel is 13... not any other. So it's quite frustrating for me that my Mac cannot use it properly when my router (bought in here) is standing 1 meter away from my Mac.
It turns out that some nasty neighbor of mine has a Canadian router which sets my Mac's Airport to country code CA. This renders channels 12 and 13 useless for me. Since I can't vaporize my neighbor's router, I'm left wondering why is it that all other WiFi gadgets in my house work properly under channel 13 ? (I mean they all have wireless cards in there.. you could say the Mac is following the specification correctly and setting the country code to the first network is picks up but this is assuming a lot of things). Anyway it's pretty frustrating...
There was a script I found that would reset the WiFi card continuously until it picks up the right setting. I made a slight modification so that it really expects to see channel 12 (which then means 13 is also available) in the list of supported channels (whereas the original expected to see the wifi types g/n/ etc). Must be run with sudo and it "works around" the issue for me right now but I find it very stupid having to turn the WiFi on and off until it works... and not sure if it's very good for the hardware to turn it on and off intermitently..
Anyone found a better solution by now ?
Anyway here's the script... save it to a file and run it in the terminal with "sudo ./youscript.sh"
#!/bin/bash
# This script will turn the AirPort on and off
# until the country code is different from "SY"
#
# author: Martin Bartos (f1lth@msn.com)
# modified: Szilveszter Molnar (mail@moszi.net)
if [[ $EUID -ne 0 ]]; then
echo " This script must be run as root" 1>&2
exit 1
fi
cont=1
while [[ $cont -ge 1 ]]; do
echo
log=`system_profiler SPAirPortDataType |grep "Supported Channels:" | cut -d "," -f 12`
if [[ $log != " 12" ]]; then
echo $log
echo -n " Restarting AirPort [$cont] ... "
sudo networksetup -setairportpower en1 off
sleep 6
sudo networksetup -setairportpower en1 on
sleep 2
let "cont+=1"
echo " DONE"
else
echo $log
echo " Happy Networking "
echo
cont=0
fi
done
exit 0
MacBook Pro, Mac OS X (10.7.2)