• ARTICLES
SEARCH

How-To Geek

Change your Network Card MAC Address on Ubuntu

There are a lot of reasons you might want to manually set your MAC address for your network card. I won’t ask you what your reason is.

To change this setting, we’ll need to edit the /etc/network/interfaces file. You can choose to use a different editor if you’d like.

sudo gedit /etc/network/interfaces

You should see the line for your network interface, which is usually eth0. If you have dhcp enabled, it will look like this:

auto eth0
iface eth0 inet dhcp

Just add another line below it to make it look something like this:

auto eth0
iface eth0 inet dhcp
       hwaddress ether 01:02:03:04:05:06

Obviously you would want to choose something else for the MAC address, but it needs to be in the same format.

sudo /etc/init.d/networking restart

You will need to restart networking or reboot to take effect.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 12/31/06

Comments (31)

  1. PhinnFort

    Try to apt-get macchanger. Much easier to use.

  2. maddin

    via bash:

    1) sudo ifconfig down
    2) sudo ifconfig hw ether 11:22:33:44:55:66
    3) sudo ifconfig up

    thats it

  3. Jacob Rhoden

    The ifconfig method will only temporarily change your mac address.

  4. procuro

    try this:

    sudo gedit /etc/init.d/bootmisc.sh

    on the bottom of the page, insert:

    killall dhclient
    killall dhclient3
    ifconfig eth0 down
    ifconfig eth0 hw ether 112233445566
    ifconfig eth0 up
    /sbin/dhclient
    /sbin/dhclient3

    anything in this file will load after the regular boot process is started up. So putting this in the file will change the mac address everytime the machine starts.

  5. Doni

    This script is good. But not working localhost & azureus etc.
    You must apply:

    sudo gedit /etc/network/interfaces

    And paste in this file:

    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet dhcp
    hwaddress ether XX:XX:XX:XX:XX:XX

  6. DX

    The tutorial dosn’t work for me. Don’t know why.
    Then I tryed procuro’s method and it works but just for a minute. Then my laptop dies, gets blocked and I can’t do nothing.
    I have a wired connection and generated ip.

  7. DX

    I found this:
    ****************************************************************
    Open terminal and type as follow:

    $ ifconfig

    $ cd /etc/init.d

    $ sudo nano ChangeMAC

    Then, fill configuration file with new MAC Address.
    sudo ifconfig eth1 down
    sudo ifconfig eth1 hw ether xx:xx:xx:xx:xx:xx
    sudo ifconfig eth1 up
    sudo /etc/init.d/networking stop
    sudo /etc/ini.d/networking restart

    Save and close the file

    Apply configuration file.
    $ sudo chmod +x ChangeMAC

    $ sudo update-rc.d ChangeMAC defaults

    Restart machine, and check new MAC Address with ifconfig command.
    ****************************************************************

    WORKS JUST FINE!

  8. The Geek

    @DX

    Thanks for the update, I’ll test and change the article. I’m guessing when I wrote this it worked for an older version of Ubuntu, but not anymore.

  9. typo

    small typo in last line of DX’s script, should be /etc/iniT.d/networking restart

    thanks, btw!

  10. Jhom

    Hi,
    Tried all the options (not together :D), but no one didn’t fix the problem for me.
    with ipconfig I still have my eth0 with my old mac adress.
    Anyone new ideas?
    Thanks,

    Jhom

  11. HIBRA

    hi
    I did what in the DX’s script exactly,and when I restart the machine a white screen appeared
    after I logged in and I couldn’t get my desktop again
    the computer is now waiting…….
    for your solutions

    thanks

  12. vas

    Open terminal and type as follow:

    $ ifconfig

    $ cd /etc/init.d

    $ sudo nano ChangeMAC

    Then, fill configuration file with new MAC Address.
    sudo ifconfig eth1 down
    sudo ifconfig eth1 hw ether xx:xx:xx:xx:xx:xx
    sudo ifconfig eth1 up
    sudo /etc/init.d/networking stop
    sudo /etc/init.d/networking restart

    Save and close the file

    Apply configuration file.
    $ sudo chmod +x ChangeMAC

    $ sudo update-rc.d ChangeMAC defaults

    Restart machine, and check new MAC Address with ifconfig command.
    ****************************************************************

    WORKS JUST FINE!am trying this now, i will let u know if it worked!

  13. vas

    try this:

    sudo gedit /etc/init.d/bootmisc.sh

    on the bottom of the page, insert:

    killall dhclient
    killall dhclient3
    ifconfig eth0 down
    ifconfig eth0 hw ether 112233445566
    ifconfig eth0 up
    /sbin/dhclient
    /sbin/dhclient3

    anything in this file will load after the regular boot process is started up. So putting this in the file will change the mac address everytime the machine starts.

    this one worked in the newest Ubuntu distro year 2009 jan/feb.

  14. vas

    ill test the other once to, if their are people who know more script or command ideas of changing mac address than post here, ill test those to!

  15. miRo

    All the time I was using the ifconfig method in some /etc/init.d startup scripts (without changemac program), but now i tried the solution from original post and i find it the best. It’s very clean, i just added the line “hwaddress ether 01:02:03:04:05:06″ to /etc/network/interfaces and after restart everything works like a charm…

  16. miRo

    oh, i almost forgot… works under Debian 5.0 Lenny {stable}

  17. unknown

    [b]for mac osx users:[/b]

    sudo ifconfig en1 ether (mac-address)
    *this will spoof your mac-address*
    ifconfig en1 |grep ether
    *this will show you your current mac-address*

  18. aron

    sudo ifconfig eth0 down
    sudo ifconfig eth0 hw ether 00:a0:WH:AT:EV:ER
    sudo ifconfig eth0 u

  19. kees

    DX’s method does work properly.

  20. ubuntu user

    I tried DX’s method and it worked but now i can’t connect to a network,
    does anyone know how to revert back to defaults, i changed my mac address back to the original
    in hte ChangeMAC file but still no connection,

    i just wanted to know how to take out the nano ChangeMAC stuff

    thanx

  21. Al1en

    there’s program in GTK called MACchanger ;)
    someone may try it, heres the .deb pack for ubuntu

    http://packages.ubuntu.com/maverick/macchanger

  22. P-Ush

    $sudo apt-get install macchanger
    $sudo macchanger -r eth0

    This works very well! :) Thanks Phinn Fort!

  23. talishte

    Some routers don’t accept association if you are using a random mac address if the vendor is radom too then I always use

    macchanger -A eth0

  24. b.a.

    Network manager in Ubuntu 10.10 have option “Cloned mac address” which does exatly this thing! Super!

  25. Growlf

    Try just removing /etc/udev/rules.d/70-persistent-net.rules and then rebooting.

  26. raj

    how to change the lan ip address in linux ubuntu

  27. suresh chandra nathsharma

    dear sir ,
    i am auser of ubuntu-10.10
    my laptop model is compaq preserio cq40-601tu
    i want to install all the driver which i required to get a complite laptop.
    plz sir give me the idea.

  28. Johan

    “b.a.
    Network manager in Ubuntu 10.10 have option “Cloned mac address” which does exatly this thing! Super!”

    in Ubuntu 10.10
    device mac address = HWadr from iconfig ?!

    what is the “cloned mac address” ?
    anything I might find in a dream?
    or device = clone ?

    MTU = automatic?

  29. jonny rocket

    tanks yuo. much happy now.

  30. Aleks

    Can some one tell how to change MAC in DEBIAN 6 Command line no Grafikcs!
    and DHCP auto ?????????

  31. Crosility

    Thank you. This helped. I was having a problem where if I dual-boot windows, my etho connection would be owned by windows by my router. When I switched back to linux, I’d need to do a manual reboot of the router for my etho to be assigned to linux. The problem wasn’t vis-versa.
    By doing this, my endings are now db, and dc, for the same etho card, allowing linux to have the card, and windows, regardless when I switch on the dualboot. Thanks again!

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!