If you want to check that the spoof worked, type the same command as earlier:
ifconfig en1 | grep ether
Now you will see:
ether 00:e2:e3:e4:e5:e6
For the wired ethernet port:
sudo ifconfig en0 ether 00:e2:e3:e4:e5:e6
Shows only IP-addresses of ifconfig except 127.0.0.0/8. I fixed the script to work on more systems and configs short info /inet/!d; #grep inet /127.0/d; # grep -v 127.0 /dr:\s/d; # grep -v dr: s/^.*:\(.*\)B.*$/\1/ # remove everything exept between : and B
Command is properly working on HP-UX 11.31 Show Sample Output
The 00:11:22:33:44:55 is whatever you want your new MAC address to be. Sometimes sudo should be used in front if you need to.
Is the better option on a Open SuSE Box
Print the IP address and the Mac address in the same line Show Sample Output
not shown ifconfig error
Simple MAC adrress, thanks to ifconfig.
Gets the IP addresses of all interfaces except loopback. Cuts out all of the extra text. Shorter than the other options, and much easier to type. 'ifconfig | grep cast' is enough to get the IP address, but it doesn't strip the rest of the junk out. Show Sample Output
only output the ip addres. I put double pipe with sed because not parse with operator OR (|) in redex. Show Sample Output
This also works on non-Linux machines. If you have GNU sed you can do it more elegantly:
ifconfig | sed -n 's/^\s*inet \(addr:\)\?\([^\s]*\) .*/\2/;T;/^127\./d;p'
Just replace eth3 with the interface you want the MAC for. Show Sample Output
plain and simple Show Sample Output
Why use grep and awk?
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: