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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s