How to get the IP address of RDS instance in AWS [closed]
Asked Answered
L

8

25

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?

Lamia answered 26/1, 2015 at 12:9 Comment(0)
B
25

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.

Biel answered 24/1, 2017 at 18:57 Comment(2)
And the navigation is select instance & show Details->Connect->EndpointBurnette
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.Continuity
G
12

Use this:

SELECT inet_server_addr();
Grogram answered 1/2, 2019 at 22:20 Comment(3)
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 connectionHowerton
where to use this?Julienne
it shows me 172.31.46.141 - I think it's 'Internal' IPLunate
B
11

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.

Batangas answered 26/1, 2015 at 12:23 Comment(2)
@Vivek How can we know the ip address then ?Barocchio
on RDS detail page it should display you IP or hostname.Headlong
M
5

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.
Malar answered 11/3, 2021 at 5:51 Comment(4)
The question is about RDS, not a database running in EC-2Andreaandreana
Yes the question is about RDS. But the RDS instance will use IP address(es) in its configured subnets, and the network interfaces and IP addresses of them are indeed visible in the Network Interfaces screen of the EC2 web console. The tricky part is, if you have more than one RDS instance in the same region and VPC, telling which interfaces and IPs belong to which RDS instance. If you have only one RDS instance in the region and VPC, that makes it easy.Execution
Thanks for that answer! In my case DNS resolution didn't work, therefore this was the only solution.Splitlevel
You can identify RDS interfaces with the description column RDSNetworkInterface in Network Interfaces.Sugihara
T
4

Simple method to find RDS ip address: Open command prompt from local machine and ping your RDS Endpoint. You will see the reply from destination host ip address. That is your RDS ip address! Regardless if it is public accessible or not.

Tape answered 14/6, 2021 at 23:54 Comment(2)
I would like to add with this approach, once you get ip after doing ping to your DB endpoint, copy that ip and search for that ip at Network Interface to get it's private ip.Marchpane
Is it possible to get the range of IPs? Because Ping will display only 1 IP and it could be changedif we have RDS with DHCPLunate
R
2

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') 
Riles answered 13/3, 2019 at 0:46 Comment(0)
H
1

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

Helbona answered 3/1, 2020 at 20:34 Comment(1)
.us-east-1.rds.amazonaws.com: Query refusedLunate
D
1

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

Dropsical answered 10/10, 2020 at 15:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.