I wonder, why can't I change my mac address by doing this:
sudo ifconfig wlan0 down
sudo ifconfig wlan0 hw ether 03:a0:04:d3:00:11
The error is SIOCSIFHWADDR: Cannot assign requested address
I googled but found nothing valuable.
P.S As usual, I can't do this. Nothing works. I took the new mac address which was incremented by 1 from my current one (old 11:11:11:11:11:cf, new 11:11:11:11:11:d0)
sudo ifconfig wlan0 down
sudo ifconfig wlan0 hw ether 11:11:11:11:11:d0
There was no error, it even connected to wifi automatically after I did this (even though I didn't do sudo ifconfig wlan0 up)
. I though it won. However, when I did
sudo ip addr
I've seen the same mac address as it had before. Nothing was changed.
03:a0:04:d3:00:11
is not an unicast address as the first octet needs to be even. Look at the image below to understand it better. This image is from Wikipedia - MAC address pageso put instead
02:a0:04:d3:00:11
for exampletry this out c what happens actually there is a particular pattern of mac address which is only registered one so with a random mac address you can't change the address.
Best of luck
I assume that because you are trying to change the HWaddr of your wireless interface, that you are attempting some wireless pentesting and need to spoof your HWaddr. Well there are a few ways to do this but I will give you my method since I have not seen it included here. The following bash shell code is a very basic random HWaddr generator that I created. It isn't perfect and does have some bugs (such as certain generated MACs not being allowed to the device).
Here is the random HWaddr function for bash:
Now I will explain what is going on with this function:
RAND_MAC()
is going to be the function declaration. This is pretty much letting the bash shell interpreter know "Hey, there is a function here." and for it to look for open and close braces{}
. After theRAND_MAC()
function is declared, there is a single{
followed by a nested new function declaration calledgen()
. Nested pretty much just means a function inside a function. Thegen()
function is what will randomly generate the octets of the random HWaddr.gen()
is a self-contained function and only activates during thefor
loop below it executes. Whengen()
is called, a variable calledNUM
is assigned the value of a command's output. The command whichNUM
is being assigned is$(tr -dc '0-9a-f' </dev/urandom | head -c 2)
. This will output a 2-character string using numbers0-9 and lower case letters
a-fin random order by pulling from
/dev/urandom`.So now that the function
gen()
is pretty much explained, the rest of the main functionRAND_MAC()
is going to control the show. Thefor
loop will iterate 6 times. After the 6th iteration, thefor
loop moves todone
and it is finished. The result is a freshly generated HWaddr you can now use with yourwlan0
interface or whatever your interface is named. The reason we are using bash functions for this is to keep the data of this script from being in a global scope. We want to keep such scripts local to eliminate errors that I won't get into here. Once you have the function saved to a file, such as something like/usr/bin/macgen
, give it permission to be executed.Now your new HWaddr-generating script is ready to use whenever you want from the terminal command line. You can call the tool by using the command,
macgen
.Now comes how to assign this new HWaddr using the method that hasn't been given.
Many have suggested using
ifconfig
or maybe eveniwconfig
for changing your wireless interface's HWaddr. Well,ifconfig
and eveniwconfig
are depreciated tools and have pretty much been superseded by the tools calledip
andiw
. The tool I will use in this answer isiw
. The following commands will be what you need to follow to create a virtual interface, spoof it's HWaddr, and prevent having to change your real physical hardware's HWaddr. This method, to me, is much more sane and safer since we can simply bring our real physical interface down withifconfig
and use a completely virtual and fake interface to do all that we want:First, we will generate the new HWaddr to use.
Then we will use
ifconfig
to bring the real device down.Now we can create the VNIC with
iw
.And finally, we bring the interface up.
Now you should have a spoofed wireless interface in monitor mode as well as a spoofed mac address for that interface. If you need to change it's mode from monitor to managed so that you can use it to connect to an access point just do the following:
Bring the VNIC down:
Change the mode:
[Quick note] Before changing the mode, make sure all other managed mode interfaces are down otherwise, you will toggle an error flag with
iwconfig
.Bring interface back up:
Check to make sure the configurations are correct with:
The output should look similar to this:
And when you are ready to get rid of the VNIC, just delete it:
And then bring your real interface back up:
Hope this information helps. Feel free to ask if you are confused about any of this.
As you know only macchanger is a tool to change mac address in Linux. For changing wlan0 interface type ifconfig wlan0 down macchanger -r wlan0 ifconfig wlan0 up -r for random change (automatic) You can get here a deatail list from Here
http://www.microhowto.info/howto/change_the_mac_address_of_an_ethernet_interface.html
SEE THIS
it says the fist number should be a even number it worked for me