Running the following commands appears to correctly set all the forms of hostname on my Lucid ec2 instance:
echo "$(curl -s http://169.254.169.254/latest/meta-data/local-hostname)" | sed 's:\..*$::' > /etc/hostname
/sbin/sysctl -w kernel.hostname="$(curl -s http://169.254.169.254/latest/meta-data/local-hostname | sed 's:\..*$::')"
logout/login shell
root@ip-10-XXX-181-59:~# uname -n ip-10-XXX-181-59 root@ip-10-XXX-181-59:~# hostname -s ip-10-XXX-181-59 root@ip-10-XXX-181-59:~# hostname -d ec2.internal root@ip-10-XXX-181-59:~# hostname -f ip-10-XXX-181-59.ec2.internal root@ip-10-XXX-181-59:~# hostname ip-10-XXX-181-59 root@ip-10-XXX-181-59:~# echo $HOSTNAME ip-10-XXX-181-59 root@ip-10-XXX-181-59:~# cat /etc/hostname ip-10-XXX-181-59 root@ip-10-XXX-181-59:~# /sbin/sysctl -n kernel.hostname ip-10-XXX-181-59
Running the following commands appears to correctly set all the forms of hostname on my Lucid ec2 instance:
echo "$(curl -s http:// 169.254. 169.254/ latest/ meta-data/ local-hostname)" | sed 's:\..*$::' > /etc/hostname
/sbin/sysctl -w kernel. hostname= "$(curl -s http:// 169.254. 169.254/ latest/ meta-data/ local-hostname | sed 's:\..*$::')"
logout/login shell
root@ip- 10-XXX- 181-59: ~# uname -n 10-XXX- 181-59: ~# hostname -s 10-XXX- 181-59: ~# hostname -d 10-XXX- 181-59: ~# hostname -f 181-59. ec2.internal 10-XXX- 181-59: ~# hostname 10-XXX- 181-59: ~# echo $HOSTNAME 10-XXX- 181-59: ~# cat /etc/hostname 10-XXX- 181-59: ~# /sbin/sysctl -n kernel.hostname
ip-10-XXX-181-59
root@ip-
ip-10-XXX-181-59
root@ip-
ec2.internal
root@ip-
ip-10-XXX-
root@ip-
ip-10-XXX-181-59
root@ip-
ip-10-XXX-181-59
root@ip-
ip-10-XXX-181-59
root@ip-
ip-10-XXX-181-59