Change Mac OS X Wireless Card Country Code

I have problem connecting to a wireless router using Mac OS X which is on channel 13. This is because there is some other router nearby which is broadcasting the US country code. The only way around this i have found so far, is to each time go to the router and restart the computer.

I have asked google and it seems to be a mixture of people who think that it is setting the locale changes it, or that it is fixed in the router firmware. Both i have shown to be wrong. man ifconfig also has not been too enlightening.

Does anyone know of another way to force the card to use a different country Code or channels? I would rather not change to another channel, as there is alot of interference near by (shown with KisMAC).

Thanks


Edits

Found

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

Which appears to allow for an arbitary channel to be set on the card, but not county code. This seems to have no effect.


Solution 1:

802.11d is the protocol that wireless access points use to broadcast (among other things) the regulatory domain (i.e. country codes) in which it is supposed to be operating. It seems that there may be no clear rule for what to do when various equipment is broadcasting conflicting regulatory domain information.

The ideal solution would be to disable/replace/reconfigure the equipment that is broadcasting the incorrect information.

I found an (oldish) Apple Discussions thread that indicates that indicates that a Mac’s AirPort hardware will use the first country code it hears after powering on or waking from sleep. Later postings in the thread (on the second page) indicate that it is sufficient to just power off/on the AirPort hardware itself and not the whole system. A couple of people reported success using a script to repeatedly turn the AirPort interface off and on (using networksetup) until it happened to acquire the desired state (as reported by system_profiler).


Based on TA25972, it seems that older equipment (presumably models that do not listen for 802.11d information) may not even be able to switch “country codes”.

Solution 2:

I got this problem to, and I solved it!

All I wanted to do is to disable the 802.11d beacon function. This is impossible to do in any available settings on the Mac OS X.

However you can binary patch the network card driver thinking the country code is always X2.

So apparently, what I would have to do is change/binary patch the network driver with the string 0x81 0x78 0x30 0x6B 0x10 0x00 0x00 0x0F 0x85 to 0x81 0x78 0x30 0x6B 0x10 0x00 0x00 x90 0xE0. This forces the driver to use country code «X2» whatever beacon is being sent, so it will never change.

You could either change this with a hex-editing utility or copy and paste the following very handy one-liner in the terminal application:

sudo perl -pi -e 's|\x81\x78\x30\x6B\x10\x00\x00\x0F\x85|\x81\x78\x30\x6B\x10\x00\x00\x90\xE9|' /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/MacOS/AirPortBrcm4360 && sudo touch /System/Library/Extensions/

This solution works for Mac Book Pro Retina 2013.

Solution 3:

the problem come from the implementation of 802.11d : wifi location and country ID conflicts. if there are different wifi Access points broadcasting mixed countries ID, Mac OS may shut down certain frequencies.

Solution at the end of the post :)))

Just after a restart my MacBook Pro 16 is set to locale ETSi and country code X3 All channels and frequencies are opened.

If i stop and restart the wifi, or the Mac goes in power save mode and turn off the radios. When it wakes up i got this: Country code ID, and most of the supported channels are gone.

There's a lot of posts about this on the internet, about either adding another AP and setting county code. Some APs (like mikrotik don't broadcast country codes) Some posts are about modifying the wifi drivers.

Don't do any of that, the solution is quite simple !!!

I'm now on MacOS 11.0.1 Big Sur. But i assume the solution is the same on previous MacOS Versions

Go to:

  • Apple Menu -> System preferences
  • Security & Privacy -> Location Services
  • Scroll down till you find System Services
  • Click on Details...
  • Uncheck WiFi Networking

This will bypass 802.11d implementation and 5ghz will show up right away