- Generates and assigns a random MAC address to my wired card (eth0) and wireless card (wlan0) using the macchanger software described here
- Generates and assigns a new hostname to my OS
- Applies the new changes in my "/etc/hosts" file
- Runs on every startup
Here is the script:
!/bin/bash
#random_computer_name & random MAC address for both eth0 and wlan0
sudo macchanger -A eth0 #random mac for eth0
sudo macchanger -A wlan0 #random mac for wlan0
sed -i 1,10d /etc/hostname
function randnum
{
number=$[ ( $RANDOM % 15 ) + 8 ]
}
randnum
function randpass
{
newhostname=`
}
randpass
(echo '0a'; echo $newhostname; echo '.'; echo 'wq') | ed -s /etc/hostname
/bin/hostname $newhostname
sed -i '$d' /etc/hosts # deletes the last two lines in /etc/hosts
sed -i '$d' /etc/hosts
echo -e "127.0.0.1 $newhostname localhost\n127.0.1.1 $newhostname" >>/etc/hosts
You can add the above file to your startup following the steps in this link
Appreciate any feedback. Note: I'm already working with this script on my laptop and it's working fine till now, I just had about 10 seconds idle at the startup screen.
Update: That delay happened only after the first startup and then disappeared
No comments:
Post a Comment