Answer the question
In order to leave comments, you need to log in
How to generate hostname from IP?
I need the machines that I raise on the hypervisor to receive the hostname as well as the IP when they start up (so that the hostname is unique for each VM). How to do it without shamanism, who knows?
ps instead of localhost I want to receive 192.168.1.*...
Answer the question
In order to leave comments, you need to log in
Push a simple script into autoload:
IP=$(ifconfig eth0 | awk '/inet addr/{print substr($2,6)}')
ID=$(echo $IP | sed -e 's/\.//g' | cut -c 7-)
HOSTNAME=$ID.local
echo $HOSTNAME > /etc/hostname && service hostname restart
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question