Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to get a random mac address everytime I turn on my linux machine (debian). Is this possible? If so, how?

share|improve this question

closed as off-topic by jasonwryan, Anthon, Zelda, Herman Torjussen, slm Jan 11 at 13:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – jasonwryan, Anthon, Zelda, Herman Torjussen, slm

1  
It's possible, but it provides no meaningful privacy at all. You can go to a restaurant in a different disguise under a different name every day and fool absolutely no one. Random MACs are about the same level of effective; don't bother. –  msw Aug 24 '13 at 2:59
    
@msw : Seems to me that would depend on context. For example, if you are literally walking into the same restaurant everyday and using the free wifi, spoofing your MAC address does provide privacy. It is the only way that your day after day presence could be logged, or recognized. –  goldilocks Aug 24 '13 at 5:53
1  
NOTICE: This question has been crossposted to another SE group! This is very bad practice. –  mdpc Aug 24 '13 at 6:36
    
@goldilocks there is a whole domain of "traffic analysis" which suggests exactly the opposite. Keeping to my silly example, if anyone was watching and cared, being the guy in the restaurant with the random MAC every day would identify you as surely as does the "hand" of a telegraph operator. And although you would be spoofing the data-link layer, being the guy who downloads pictures of calico kittens each time he enters would mark you far more vividly than anything else ("Don't know who he is, but he sure likes his calicos"). –  msw Aug 24 '13 at 10:35
    
@mdpc which other SE site did you see this? The OP has only an account on Unix/Linux –  Anthon Jan 11 at 9:53
show 2 more comments

1 Answer 1

It is possible, look at How to change MAC address, posted at September 14, 2005 by Ravi.

Changing MAC address of a machine is called spoofing a MAC address or faking a MAC address. In linux, you can change MAC address of your machine.This is how it is done.

How to change MAC address in Linux

First find the physical MAC address of your machine by running the following command:

$ ifconfig -a | grep HWaddr
eth0  Link encap:Ethernet HWaddr 00:80:48:BA:d1:20

The hexadecimal numbers in blue denote my machine's MAC address. Yours will be different. Learn how to use the ifconfig Linux command.

You can also use ethtool to find the hardware address of your machine.

Next, login as root in Linux and enter the following commands:

# ifconfig eth0 down
# ifconfig eth0 hw ether 00:80:48:BA:d1:30
# ifconfig eth0 up
# ifconfig eth0 |grep HWaddr

I have changed the MAC address to a different number highlighted in blue. 00:80:48:BA:d1:30 is the new MAC address I have provided for my Linux machine. You can choose any 48 bits hexadecimal address as your MAC address.

Why you should change MAC address of your Linux machine

These are the reasons you should change the MAC address of your machine.

  • For privacy - For instance when you are connecting to a Wi-Fi hotspot.
  • To ensure interoperability. Some internet service providers bind their service to a specific MAC address; if the user then changes their network card or intends to install a router, the service won't work anymore. Changing the MAC address of the new interface will solve the problem.

Caveats to Changing MAC address

In Linux, Windows, Mac OS X, or a different operating system, changing MAC address is only temporary. Once you reboot your machine, the operating system reflects the physical MAC address burnt in your network card and not the MAC address you set.

Still if you are looking for privacy as @msw pointed out I would go the TOR way.

share|improve this answer
    
+1 for answering the weak question. Added caveat: being the "guy who uses TOR" would mark you in traffic analysis far more clearly than any MAC ever could. Put another way: even if I brought in a different real device every day but had the same habits, I'd fool no one who cared. –  msw Aug 24 '13 at 10:41
3  
I also got creative and worked out a random mac generator: dd if=/dev/random bs=2 count=3 2>/dev/null | perl -e '$hex = <>; $hex = unpack("H*", $hex) ; $hex =~ s/(..)(?!.?$)/$1:/g; print "$hex\n";' –  Drav Sloan Aug 24 '13 at 12:15
    
@msw so which are the alternatives? Using an open proxy? I`ve used a reverse proxy to circunvent firewalls but I'm aware they can see me. –  vfbsilva Aug 24 '13 at 15:25
    
Alternatives are strictly dependent upon what you're trying to hide from. If, for example, you've got a government agency which is very interested in your activities, the answer is usually "nothing". Of course there are lesser degrees of interest, but I know that a forged MAC protects you against only distracted 6-year-old kids and similarly uninterested parties. In between those poles I truly have no idea of what's effective and not. –  msw Aug 24 '13 at 16:30
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.