Pages

Tuesday, August 2, 2011

checking Ip address of amazon after reboot

every time you reboot or stop/start an instance, you are assigned new public and private IP addresses and hostnames
with this script you can get the new IP and hostname of instance, so that you can use it later

#!/bin/sh
META=http://169.254.169.254/latest/meta-data
HOSTNAME=`/usr/bin/curl -s $META/hostname | /bin/sed 's+\..*++g'`
hostname $HOSTNAME
echo $HOSTNAME > /etc/hostname
IPV4=`/usr/bin/curl -s $META/public-ipv4

http://169.254.169.254 is an internal Amazon EC2 server that will report information about your instance—very helpful if you haven’t installed the EC2 API tools

No comments:

Post a Comment