windows - How to figure out the 'Public DNS Name' from within an Amazon EC2 instance? -
i have windows 2008r2 instance on amazon ec2. able access "public dns name" within instance. public dns name can found on aws ec2 console.
is there way this?
unknown's answer technically correct (+1), in order provide background , more details, i'd mention respective amazon ec2 instance metadata , user data:
instance metadata data ec2 instance can use configure or manage running instance. instance metadata divided categories. more information, see instance metadata categories.
one of many available metadata categories public-hostname
:
the instance's public dns. if instance in vpc, category returned if enablednshostnames attribute set true. more information, see using dns vpc.
you can retrieve instance metadata within running ec2 instance via dedicated uri http://169.254.169.254/latest/meta-data/
http capable tool, e.g. ubiquitous curl, highly recommended httpie (a cli, curl-like tool humans) , of course, obvious use case, powershell, esp. version 3.0+, e.g.:
ps> $publichostname = invoke-webrequest ` -uri http://169.254.169.254/latest/meta-data/public-hostname
Comments
Post a Comment