Randomize Hostname and Renew IP

#!/usr/bin/env bash
 
echo +++++++++++++++++++++++++++++++++++++++++
echo Randomize Hostname and Renew IP
echo  by Aung Khant, http://yehg.net
echo +++++++++++++++++++++++++++++++++++++++++
echo
 
########################################################
sleep 1
 
#Get Random String
#Ref: http://tldp.org/LDP/abs/html/string-manipulation.html#RANDSTRING
 
POS=2  # Starting from position 2 in the string.
LEN=8  # Extract eight characters.
str0="$$"
str1=$( echo "$str0" | md5sum | md5sum )
# Doubly scramble:     ^^^^^^   ^^^^^^
 
randstring="${str1:$POS:$LEN}"
# Can parameterize ^^^^ ^^^^
 
# Set it to Hostname
echo
echo [*] Randomizing hostname ..
echo 
hostname $randstring
echo -en Your new hostname is "\E[32m$randstring"
tput sgr0;
echo 
echo 
sleep 2
 
 
########################################################
#Renew IP
echo
echo [*] Renewing IP with random MAC
echo 
 
ifconfig eth0 down
sleep 1
macchanger -r eth0
echo 
sleep 1
ifconfig eth0 up
sleep 1
/etc/init.d/networking restart
ifconfig | grep "inet addr:"
 
echo
echo [*] Done
echo

Submitted by Aung Khant