Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have recently pieced together a script with my limited knowledge of bash that is supposed to do 2 things:

  1. It is supposed to change my hostname
  2. and then change my mac address.

I put the instructions directly into /etc/rc.local on my backtrack 5 r3 machine, but I can't seem to get it to change my mac address. macchanger is already installed. It changes my hostname fine, but it doesn't seem to want to change my mac address. Could this be because my machine is running in virtual box?

Here is what I put into /etc/rc.local:

dhclient -r && rm -f /var/lib/dhcp3/dhclient* && sed "s=$(hostname)=REPLACEME=g" -i /etc/hosts && hostname "$(echo $RANDOM | md5sum | cut -c 1-7 | tr a-z A-Z)" && sed "s=REPLACEME=$(hostname)=g" -i /etc/hosts && macchanger -e eth0 && macchanger -e wlan0 && dhclient

I tried it like this, with the && operators, and I also tried it by putting a command on each line. The hostname changes each time but the MAC address doesn't.

Any help would be appreciated!

share|improve this question

2 Answers 2

Try to write the results of macchanger -e eth0 and macchanger -e wlan0 to a file. And look, if the devices exist with that name during startup with ifconfig. E.g. put this into your /etc/rc.local:

macchanger -e eth0 &> /tmp/devices.txt
macchanger -e wlan0 &>> /tmp/devices.txt
ifconfig &>> /tmp/devices.txt

Explanation:
&> /tmp/devices.txt writes the standard output and standard error output to the file /tmp/devices. After starting your machine you can look into this file and maybe get a hint from that.

share|improve this answer

Thanks for the rely, I already attempted this, but It didn't work. It appears that something prevents macchanger from running before I type in "startx". I guess I can only run it in the upper rings? I did put the commands in another file, and I also did the command chmod +x for the file, as well as "sudo /etc/init.d myfile defaults" Which said it added the file to all of the rc1.local-rc5.local. I finally just put the file path into my startup programs in the gui and now after I run startx it changes the mac address.

EDIT: whoops, wrong gmail account. Ill repost this as the right account.

share|improve this answer
    
Thanks for the rely, I already attempted this, but It didn't work. It appears that something prevents macchanger from running before I type in "startx". I guess I can only run it in the upper rings? I did put the commands in another file, and I also did the command chmod +x for the file, as well as "sudo /etc/init.d myfile defaults" Which said it added the file to all of the rc1.local-rc5.local. I finally just put the file path into my startup programs in the gui and now after I run startx it changes the mac address. –  user183559 Dec 31 '12 at 6:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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