Subscribe to How-To Geek

Recommended: Click Here to Run a Free Scan for Common PC Errors   [Sponsored Link]

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.

The Geek is the founder of How-To Geek and a geek enthusiast. When he's not coming up with great how-to articles, he's probably writing at his personal blog. This article was written on 12/31/06 and tagged with: Ubuntu

Comments (9)

  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!


Leave a Comment




Leave your friendly comment here. If you have a computer help question, leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.