permanent change of MAC address in Mac OS X

Discussion in 'iMac' started by Apoph, Apr 6, 2011.

  1. Apoph macrumors newbie

    Joined:
    Apr 5, 2011
    #1
    Hi there.
    Basically, the title says all.
    I have question - how to change MAC address in Mac OS X permanently?
    I've tried using "sudo ifconfig en0 ether 00:01:02:03:04:05",
    but changing the MAC address in this way is not permanent: after a reboot, it will revert to the MAC address physically stored in the card. So, is there a way to change it once and for all ?
     
  2. old-wiz macrumors G3

    Joined:
    Mar 26, 2008
    Location:
    West Suburban Boston Ma
    #2
    The original address is hard encoded in the hardware. Any changes will be temporary and there's no way to do it permanently short of munging around with the hardware.
     
  3. smithrh macrumors 68020

    smithrh

    Joined:
    Feb 28, 2009
    #3
    I suppose you could put the desired MAC address in one of the launchd config files somehow, that way it would be changed at boot time.

    Caveat, I haven't learned launchd, only have been familiar with rc.boot and rc.local type config files, so maybe this wouldn't work.

    Apple sure doesn't seem to like supporting MAC address changes, you can't do this on Airport base stations either.
     
  4. Apoph thread starter macrumors newbie

    Joined:
    Apr 5, 2011
    #4
    Yeah, i need an ifconfig line to automatically change my MAC on boot. But how this can be done?
     
  5. Drewbie macrumors member

    Joined:
    Aug 27, 2010
    #5
    can you put that terminal command into an apple script?

    if you can put it in apple script you should be able to add that script to login items, which would run it upon logging into the system...
     
  6. tcassio macrumors newbie

    Joined:
    Mar 23, 2011
    #6
    I believe that you can't permantly chage any MAC address on any piece of hardware that has a nic interface. The system was designed this way to eliminate the possibility of 2 pieces of equipment from having the same MAC address.
     
  7. smithrh, Apr 6, 2011
    Last edited: Apr 6, 2011

    smithrh macrumors 68020

    smithrh

    Joined:
    Feb 28, 2009
    #7
    Lots of interfaces allow changing the MAC.

    Apple is a bit more strict here though. Why, not entirely sure.

    I understand what you're saying, MACs are supposed to be fixed but somehow over time they've become editable.
     
  8. Apoph thread starter macrumors newbie

    Joined:
    Apr 5, 2011
    #8
    I found these instructions. Will they work and is it safe to use them?


    Follow these steps to create a script that sets the MAC Address each time the computer restarts:

    1. Open Terminal (/Applications/Utilities/).
    2. Type: cd /Library
    3. Press Return.
    4. Type: mkdir StartupItems
    5. Press Return. (If you encounter an error, continue to step 6.)
    6. Type: cd StartupItems
    7. Press Return.
    8. Type: mkdir MACADD
    9. Press Return.
    10. Type: cd MACADD
    11. Press Return.
    12. Type: pico MACADD
    13. Press Return.
    14. In the pico editor, paste in the following text.

    Begin copying below this line.
    --------------------------------------------------------------------------------

    #!/bin/sh

    . /etc/rc.common

    ##
    # Configure a network interface MAC Address setting
    ##
    #
    # This script will set the MAC Address setting for the specified interface(s)
    #
    # The name of the interface (ex. en0) must be edited to match the interface
    # to which the MACADD setting should be applied
    #
    ##

    StartService ()
    {
    ConsoleMessage "Configuring MACADD"

    ### uncomment lines and change the value following 'MACADD' as appropriate mac address

    if [ "${MACADD:=-NO-}" = "-YES-" ]; then

    # /sbin/ifconfig en0 lladdr xx:xx:xx:xx:xx:xx
    # /sbin/ifconfig en1 lladdr xx:xx:xx:xx:xx:xx

    fi

    }

    StopService ()
    {
    return 0
    }

    RestartService ()
    {
    return 0
    }

    RunService "$1"

    --------------------------------------------------------------------------------

    End copying above this line.

    15. Uncomment the /sbin/ifconfig line(s) to set the MACADD for a particular interface.


    Note: Removing the number sign (#) from the beginning of a line uncomments it. Typically, en0 is the interface name for the Built-in Ethernet port and en1 is interface name for the AirPort Card. This is not always the case, though. To confirm that a network port is associated with a particular interface name, open the Network Utility (/Applications/Utilities/), and click the Info tab.


    16. When you have finished customizing the file, save it (press Control-O), press Return, and exit pico (press Control-X).

    17. Type: chmod 755 MACADD

    18. Press Return.

    19. Type: pico StartupParameters.plist

    20. Press Return.

    21. In the pico editor paste in the following text.


    Begin copying below this line.


    --------------------------------------------------------------------------------

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Description</key>
    <string>Can set MACADD</string>
    <key>OrderPreference</key>
    <string>None</string>
    <key>Provides</key>
    <array>
    <string>MACADD</string>
    </array>
    <key>Requires</key>
    <array>
    <string>Network Configuration</string>
    </array>
    </dict>
    </plist>

    --------------------------------------------------------------------------------

    End copying above this line.

    22. When you have finished customizing the file, save it (Control-O), press Return, and exit pico (Control-X).
    23. Type: chmod 755 StartupParameters.plist
    24. Press Return.
    25. Type: sudo pico /etc/hostconfig
    26. When prompted, enter your password.
    27. Press Return.
    28. In the pico editor, add this line at the bottom:

    MACADD=-YES-

    29. Save it (Control-O), press Return, and exit pico (Control-X).

    When you restart the computer, MACADD is set for the interface that you specified.

    Notes


    1. The MACADD will be reset after changing a Location, waking the computer from sleep, or changing the state of the network interface. To use the script again without having to restart, enter the following command:

    sudo SystemStarter start MACADD

    2. If you experience any issues or wish to not set MACADD during startup, you can turn off the new script by changing the MACADD line in /etc/hostconfig to:

    MACADD=-NO-

    Sorry, for a long post.
     
  9. JimMacFan macrumors regular

    Joined:
    Jan 13, 2009
    #9
    Why change MAC address? Up to no good?
     
  10. harcosparky macrumors 68020

    Joined:
    Jan 14, 2008
    #10

    BINGO !!!!


    What possible legitimate purpose could there be for changing a MAC address?

    MAC addresses are unique to each card, like the fingerprint on your fingers.

    .




    .
     
  11. Apoph thread starter macrumors newbie

    Joined:
    Apr 5, 2011
    #11
    Well some ISP bind internet connection to a certain MAC address. And i have few computers i need to connect sometimes.
    And the question was not "why do i need to change MAC address".
     
  12. harcosparky, Apr 7, 2011
    Last edited: Apr 7, 2011

    harcosparky macrumors 68020

    Joined:
    Jan 14, 2008
    #12
    Which ISP do you have that tells you to change the MAC address of a NIC?

    I mean even the IPS's know that a MAC address is hard coded and unique to each NIC.

    I've never heard of an ISP binding a connection to a SINGLE PC.
     
  13. smithrh macrumors 68020

    smithrh

    Joined:
    Feb 28, 2009
    #13
    Mine does. And it's one of the biggest ISPs out there.

    Having said that, I think the OP might look into buying a router if this is indeed the issue.
     
  14. Mastrix56 macrumors newbie

    Joined:
    Aug 9, 2013
    #14
    Thanks for the Info and a question

    Apoph,


    What types of parameters need changing in the StartupParameters.plist?

    I didnt change anything in that file and its not working for me.

    Thanks!
     
  15. jsw, Aug 9, 2013
    Last edited: Aug 9, 2013

    jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #15
    This is, by far, the best way to go about doing this.

    Get a router with an alterable MAC address, hook it up, profit.

    Edit: my apologies... I didn't realize how old this thread was prior to the reply above mine.
     
  16. tobefirst macrumors 68040

    tobefirst

    Joined:
    Jan 24, 2005
    Location:
    St. Louis, MO
    #16
    At the Panera Bread closest to my home (where they call them St. Louis Bread Co), they have a 30 minute limit on their wifi, even during non-peak times. I've changed my MAC address to get around this limitation.
     
  17. Mastrix56 macrumors newbie

    Joined:
    Aug 9, 2013
    #17
    Mobility...


    I totally agree with the router, its hard to find one that doesn't let you change the MAC. Comcast will many times install to a single PC and use the MAC of the PC NIC and limit you on the network to only that MAC address. Not always, its weird. Then you want to add devices and a wifi router and you have to spoof the address.

    I think a lot of people want to do it at the laptop layer so the MAC is protected whereever they roam. Scandalous reasons? Better security, the right to anonymity, I dont know but the script is very useful and appreciated
     
  18. CodeJynx macrumors newbie

    CodeJynx

    Joined:
    Mar 30, 2017
    #18
    I tried this and it doesn't work. Do you have another solution?

     
  19. cynics macrumors G3

    Joined:
    Jan 8, 2012
    #19
    You can change your MAC address for nefarious reasons you can also change it to protect yourself from nefarious people.
     
  20. mikeboss, Mar 30, 2017
    Last edited: Mar 30, 2017

    mikeboss macrumors 6502a

    mikeboss

    Joined:
    Aug 13, 2009
    Location:
    switzerland
    #20
    the MAC address of intel NICs can be changed permanently with "ethtool" under linux. I used this command line utility to change the PCI IDs of intel NICs, so they'll be recognized in macOS without the need to patch KEXTs. I never used it to manipulate the MAC address though. this should work:

    again: intel NICs only AFAIK

    and to be clear: this changes the MAC address in the EEPROM of the card, so this is really permanent!

    to set the MAC address to 00:07:e9:01:02:03

    # ethtool -E eth0 magic 0xDEVID8086 offset 0x0 value 0x00
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x1 value 0x07
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x2 value 0xe9
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x3 value 0x01
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x4 value 0x02
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x5 value 0x03

    DEVID of course should be the PCI ID of your NIC


    and why not use, let's say pfSense, as your gateway? there's an option to spoof the MAC address on the wan interface...
     
  21. yurc, Apr 24, 2017
    Last edited: Apr 24, 2017

    yurc macrumors member

    yurc

    Joined:
    Aug 12, 2016
    Location:
    inside your DSDT
    #21


    Recently i had done experiment from this thread, using 10GbE cards with dual ports. I had broken backplane board from my mid 2010 mac pro.

    My game plan is repurpose my previous MAC address from those broken backplane board, they have different MAC address each port. My NIC is intel X520-DA2 with dual ports with Intel MAC address, since mac pro have dual ethernet ports with different MAC address, i want assign it to my new intel NIC.

    Question : Is possible to apply Intel NIC with dual ports to assign different MAC address individually? Can you assist how looks command to assign MAC address separately each port?

    Thanks in advance.

    edit : just my guess, is this command possible? i'm using generated random MAC address with apple prefix for example.

    Example Port1 → 00:25:00:f0:1f:cd
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x0 value 0x00
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x1 value 0x25
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x2 value 0x00
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x3 value 0xf0
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x4 value 0x1f
    # ethtool -E eth0 magic 0xDEVID8086 offset 0x5 value 0xcd


    Example Port2→ 00:61:71:a5:8d:9e
    # ethtool -E eth1 magic 0xDEVID8086 offset 0x0 value 0x00
    # ethtool -E eth1 magic 0xDEVID8086 offset 0x1 value 0x61
    # ethtool -E eth1 magic 0xDEVID8086 offset 0x2 value 0x71
    # ethtool -E eth1 magic 0xDEVID8086 offset 0x3 value 0xa5
    # ethtool -E eth1 magic 0xDEVID8086 offset 0x4 value 0x8d
    # ethtool -E eth1 magic 0xDEVID8086 offset 0x5 value 0x9e
     
  22. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #22
    ethtool is linux-specific. It doesn't exist on a Mac.
     
  23. yurc macrumors member

    yurc

    Joined:
    Aug 12, 2016
    Location:
    inside your DSDT
    #23
    Off course I'm mean on linux, since I'm recently rewrite EEPROM value using ethtool. This time i want rewrite MAC address value, but still not sure how to do that on multiple ports NIC.
     
  24. mikeboss macrumors 6502a

    mikeboss

    Joined:
    Aug 13, 2009
    Location:
    switzerland
    #24
    I reprogrammed a quad-port card once. it's been some time ago but I'm pretty sure I used "eth1/2/3" for the three other ports...
     
  25. yurc macrumors member

    yurc

    Joined:
    Aug 12, 2016
    Location:
    inside your DSDT
    #25
    All right, i'll visit neighborhood linux machine and pop my card there again. This time i've also bring some fake quad port intel gigabit NIC as guinea pig before trying on my actual 10GbE NIC.
     

Share This Page