Results 1 to 3 of 3

Thread: Change/Set MAC on boot

  1. #1
    Join Date
    Aug 2009
    Ubuntu 11.04 Natty Narwhal

    Change/Set MAC on boot

    UBUNTU: 10.10
    Kernel: 2.6.35-27-generic-pae

    I wanted to be able to change my MAC address to a (virtually) random MAC when I booted (or whenever-the-hell-else I felt like it). After finding many suggestions that didn't seem to work, I found a solution that works for me so I decided to write this tut.

    The first thing you are going to have to deal with is getting rid of Network Manager (I'll call it nm from here on out).

    Why???? Even if you bring down nm, bring down your card, change the MAC address, and bring it up again...once you restart nm it fetches the real MAC and all your work is erased. Here's how I got around it:

    Install WICD (it is an nm equivalent and regarded by some as superior). To do this go to APPLICATIONS > UBUNTU SOFTWARE CENTRE search for WICD and install it. You will find it under APPLICATION > INTERNET until you reboot, after that, it shows up where nm used to - in the panel (task bar).

    Once installed ditch nm:

    sudo apt-get remove network-manager
    then install macchanger (I know you can change a MAC using ifconfig but this is the method that worked for me)

    sudo apt-get install macchanger
    Reboot your PC.

    then we need to make a file that will change your MAC on boot:

    sudo gedit /etc/init.d/changemac
    copy and paste the following into that file and save it:

    sudo ifconfig wlan0 down
    sudo macchanger -e wlan0
    sudo ifconfig wlan0 up
    exit 0
    Explanation of above:

    • sudo ifconfig wlan0 down - this takes your wireless card down (turns it off) so we can change the MAC.

    • sudo macchanger -e wlan0 - this says, 'give your wireless card a MAC that begins with a real manufacturers MAC (the first 3 segments) and randomize the next 3 segments. See notes at the bottom about the -e switch.

    • sudo ifconfig wlan0 up - this brings your wireless card back up (turns it on) with the new MAC address.

    NOTE: My card is wlan0 yours may be different. You may have to change the script to call your card. If you want to know the name of your wifi card run:

    Now we need to make sure the file is executable and included in the start-up process:
    sudo chmod +x /etc/init.d/changemac
    sudo update-rc.d changemac defaults
    Explanation of above:

    • sudo chmod +x /etc/init.d/changemac - says that this script is allowed to be executed.

    • sudo update-rc.d changemac defaults - I'm no expert but seems to me it says 'run this at start up with it's default settings'
    Now to test your work.


    You will see the MAC address (HWaddr) in the info beside the network card (wlan0). This is the real address because we haven't rebooted (run our script) yet. Make note of it!

    Reboot your PC.

    Start a terminal and run:

    Has the HWaddr changed? Perfect, you have spoofed your MAC address. Connect in privacy my friends!


    Why/What is sudo macchanger -e wlan0?

    A MAC address is unique for every damn network device in the world, it is like DNA. The first 3 segments of a MAC tell you who made that device, the last the segments are like a serial number.

    SOME (not a lot, but some) access points/routers only allow MAC's to connect if they have a real manufacturers ID (the first 3 segments). Using the -e with macchanger says "I want a random serial number but I want a REAL manufacturer".

    If you used -a (totally random MAC address) you could be denied access by a router that uses this type of filtering. Using -a you could get a MAC like:
    and even if the router let you in, that's suspicious as HELL to anyone watching.

    Using -e says "Keep my manufacturer (which is REAL) but make up the serial number (FAKE).

    This is my first TUT and is a work in progress. Written by a n00b for a n00b!
    Last edited by atomicben; April 9th, 2011 at 01:56 AM.

  2. #2
    Join Date
    Mar 2013

    Re: Change/Set MAC on boot

    Thank you for the awesome job you did on this. It should be updated according to to something along the lines of

    # Provides:          macchanger
    # Required-Start:    $network $syslog
    # Required-Stop:     $network $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Changes the MAC address at boot time.
    # Description:       Changes the ethernet and wireless cards MAC addresses
    #                    that begins with a real manufacturers MAC (the first 3
    #                    segments) and randomize the next 3 segments. 
    # Disable the network devices
    ifconfig eth0 down
    ifconfig wlan0 down
    # Spoof the mac addresses
    /usr/bin/macchanger -r eth0
    /usr/bin/macchanger -e wlan0
    # Re-enable the devices
    ifconfig eth0 up
    ifconfig wlan0 up
    exit 0

  3. #3
    Join Date
    Feb 2008
    Ubuntu 18.04 Bionic Beaver

    Re: Change/Set MAC on boot

    Thread closed. Please do not post in old threads.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts