
Apple
For the record, here’s how I set the MAC address on my MacBook Pro. As I write this it is running Leopard 10.5.6 and this has been working successfully with every version of Leopard. In fact, it has worked so well I’d forgotten how I did it, so I’m basically writing this post so, if it ever stops working, I will know how to fix it.
If it helps you, all the better. If it hurts you… well… don’t blame me.
Note that, for reasons obscure, I want to permanently set the MAC address to something other than the hardwired address. If that’s not what you want, this recipe might not be for you.
For the record I found the information on creating the startup item here.
First create a directory under the /Library/StartupItems folder.
sudo mkdir /Library/StartupItems/MACADDR
That’s MACADDR for MAC ADDRess, in case you’re wondering. I made it all caps so it would be more obvious to me in listings.
Next create the file /Library/StartupItems/MACADDR/StartupParameters.plist. I used VI, but that’s me. Use whatever editor you want.
sudo vi /Library/StartupItems/MACADDR/StartupParameters.plist
This file needs to have the following content.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> <plist version="1.0"> <dict> <key>Description</key> <string>Set the MAC address for specified interfaces.</string> <key>OrderPreference</key> <string>None</string> <key>Provides</key> <array> <string>MACADDR</string> </array> <key>Requires</key> <array> <string>Network Configuration</string> </array> </dict> </plist>
I think the Requires part is correct; I stole that from looking at the configuration files for tun and tap, since this needs to happen before the network is brought up. It might be a better idea to specify an order, but I have not had trouble leaving it as None.
Next create the file /Library/StartupItems/MACADDR/MACADDR. I think this file needs to have the same name as the directory, so if you don’t like MACADDR be sure to use the same name for both the directory and this file.
vi /Library/StartupItems/MACADDR/MACADDR
This file needs to have the following content, where ADDRESS is replaced with the MAC address you want.
#!/bin/sh . /etc/rc.common ## # Configure the MAC addresses of network interfaces. ## # # This script will set the hardware MAC address for the specified # interface(s). The name of the interface (ex. en0) must be edited # to match the interface. # # Typically the built-in ethernet card is en0, and the built-in # wifi card is en1. # ## # The start subroutine. StartService() { ConsoleMessage "Configuring MAC address" if [ "${MACADDR:=-NO-}" = "-YES-" ]; then # Make sure the wifi card has the correct MAC address. /sbin/ifconfig en1 lladdr ADDRESS fi } # The stop subroutine. StopService() { return 0 } # The restart subroutine. RestartService() { # It might be nice to make this reset the address, but it's never come up. return 0 } RunService "$1"
Again, if you change the name from MACADDR make sure to also change it in this file. Also, do not forget to replace ADDRESS with the MAC address you want to use.
These two files create a service that gets started when the Mac boots up. This “service” just sets the MAC address of the wireless card. Note that if you are running on Tiger you will probably need to use ether instead of lladdr in the ifconfig line.
If you find problems with new versions of OS X, or if I’ve done something boneheaded above, please add a comment below.
