Showing posts with label wget. Show all posts
Showing posts with label wget. Show all posts

Wednesday, May 15, 2013

EC2 (classic) instance hostname is not hostname and is not hostname


This is the results from wget and hostname at command line.
1. wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname
Output ---> ec2-50-13-20-1.compute-1.amazonaws.com
2. wget -q -O - http://169.254.169.254/latest/meta-data/hostname
Output-->   ip-10-222-1-241.ec2.internal
3. wget -q -O - http://169.254.169.254/latest/meta-data/local-hostname
output--->ip-10-222-1-241.ec2.internal
4. wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4
output--->10.222.1.241
5. wget -q -O - http://169.254.169.254/latest/meta-data/public-ipv4
50.13.20.1
6. [root@wls1 ~]# hostname  ---> linux command line
wls1.labs.oracleweblogic.com

Someone changed the host name after boot or at boot time using user-data or another method.  Normally you would see:


1. wget -q -O - http://169.254.169.254/latest/meta-data/hostname
Output ---> ip-14-222-22-28.us-west-2.compute.internal

2. hostname: hostname ---> linux command line
ip-14-222-22-28


Thursday, May 9, 2013

AWS EC2 IP address of running instance

Can use a number of methods, but these are the two that I use:
1: /sbin/ifconfig
2: wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4

The wget option assumes wget is installed. If it is not, you can issue this command to install it (as root):
 yum -y install wget