Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon EC2 - What is private DNS and private IP?

The details of Amazon EC2 mentions Public DNS, private DNS and private IP. I know public DNS can be used to reach the instance after configuring the security group.

I am not able to understand

  1. What is private DNS?
  2. What is private IP?
  3. Why do we need these number these two when we have public DNS to reach the instance?
like image 966
Gaurav Agarwal Avatar asked Dec 15 '22 10:12

Gaurav Agarwal


1 Answers

EC2 instances are connected to a private local area network and given IP addresses on that network. Those are the 10.x.x.x addresses you see as the "private IP". Amazon provides a DNS service that associates names with those private IP addresses. That's the private DNS.

Unless you are on a VPC, Amazon also connects those private IP addresses to regular routable IP addresses, and gives DNS names that resolve to those public IPs. As near as I can tell, this is pretty much just like an Elastic IP address except that each time you shut the machine down and restart it, you'll get a different one instead of the same one each time.

A neat trick with the public DNS is that the same name will resolve to different addresses depending on who is asking. Machines on Amazon's private network (that is, other EC2 machines in the same AZ, maybe the same region) will have the public DNS resolve to the private IP. That way, traffic between machines inside EC2 stays inside EC2. Machines on the regular internet will have the public DNS resolve to the public IP.

like image 121
Charles Engelke Avatar answered Jan 17 '23 16:01

Charles Engelke