19

I got the same answer everywhere on the internet regarding my question of how to get the IP address of an RDS instance in AWS, but I don't know what dig is, and how to use it.

How to allocate IP address in VPC to RDS instance?

Please help me find the IP address of my RDS instance in AWS?

user156327
  • 1
  • 4
  • 32
  • 56

8 Answers8

13

It won't display the ip address on the configuration page for the RDS instance because RDS IP's are dynamic in nature. You can dig for them if you need them but you would be better server using the DNS endpoint for the instance. This remains static and can be found on the details tab of the RDS instance within AWS.

Gareth Burrows
  • 982
  • 7
  • 20
  • 2
    And the navigation is select instance & show Details->Connect->Endpoint – Abhishek Chatterjee Mar 30 '18 at 05:20
  • In my case, I have to deal with some custom DNS (that I don't really understand), and the person who manages that DNS wanted to know the IP of the RDS instance. So yes, my apps use the endpoint, but I still needed to know how to determine the current IP. – osullic Jan 14 '20 at 13:10
7

The IP address of your AWS instance will be the IP address of the RDS instance.

If your hostname of your AWS instance is blah.blah.amazonaws.com then you can use the dig command (on Linux machines) or ping command on both Windows and Linux to find out the IP address of the host:

ping blah.blah.amazonaws.com

This will give you back the IP address of the host (something like this):

c:\ping www.google.com

Pinging www.google.com [216.58.210.100] with 32 bytes of data:
Reply from 216.58.210.100: bytes=32 time=14ms TTL=58
Reply from 216.58.210.100: bytes=32 time=15ms TTL=58
Reply from 216.58.210.100: bytes=32 time=14ms TTL=58

So the IP address of www.google.com is 216.58.210.100. dig will give you more output but the IP address is also in there. But sometimes the actual IP address of your AWS instance is actually in the hostname itself. For example:

ip-12-34-56-78.us-west-2.compute.internal

The IP address 12.34.56.78 is already in the name (depending on your instance). You can find the hostname in the AWS Console/Dashboard.

Max Worg
  • 2,824
  • 2
  • 17
  • 33
5

Use this:

SELECT inet_server_addr();
Xavier Guihot
  • 32,132
  • 15
  • 193
  • 118
Paolo Bolla
  • 51
  • 1
  • 1
  • this is the answer! great. Allowed me to use dblink to move a table between 2 Postgres instances, where using the endpoint name resulted in an error `ERROR: could not establish a connection` – Theo F Sep 04 '20 at 12:41
  • where to use this? – foobar Feb 17 '21 at 10:15
1

The answer given by Paolo Bolla is good, but only works for Postgresql.

For Microsoft SQL Server, please use:

SELECT 
  local_net_address = ConnectionProperty('local_net_address')
, local_tcp_port = ConnectionProperty('local_tcp_port') 
Xavier Guihot
  • 32,132
  • 15
  • 193
  • 118
1

You can also use Nslookup <<RDS SQL Server>> command to figure out the IP address as suggested in this AWS blog post.

burnt1ce
  • 12,985
  • 28
  • 96
  • 146
0

dig is command-line utility that finds an IP address a domain name leads to.

You can simply install it using :

apt-get update && apt-get install dnsutils -y

Then to find an IP of RDS instance (with endpoint xxx.yyy.us-east-1.rds.amazonaws.com), run the following command :

dig xxx.yyy.us-east-1.rds.amazonaws.com

In the output of dig, you will be able to find IP address in ANSWER SECTION :

;; ANSWER SECTION:
xxx.yyy.us-east-1.rds.amazonaws.com. 5 IN A 172.30.1.253

As you can see RDS instance endpoint, resolved to A type of DNS record with Private IP address

doer_uvc
  • 1,108
  • 1
  • 9
  • 27
0

This issue happens to me when I connected multiple ElasticsBeanstalk instances to the same RDS.

Ahd Radwan
  • 1,062
  • 3
  • 12
  • 29
0

On AWS Management Console - Location : AWS Management Console -> EC2 -> Network & Security, Network interfaces

  • You can see all of IP addresses and its resource's details on description tab together.
Napo
  • 237
  • 4
  • 13