How to know private ip range?

July 25, 2019 1k views
Ubuntu Debian DigitalOcean CoreOS

Hey,

Let me compare this with AWS so that I can be clearer.

In AWS I have a VPC with cidr block of 10.10.0.0/16. So I can be sure all my machines will end up with an IP within this range.

I have a service that I want to bind to an IP address which can be reached from within the private network, how can I know it’s range?

If I can’t know exactly, at least can I be sure it will start with 10. or is it possible to start with 172.?

Thanks a lot!

2 Answers

Hello @jserpa,

Actually, there is no direct way to get the range of Private IP addresses. In general, at present, we are using the 10.x range.

However, you can use the private IP address and netmask details from the metadata to get the range. You can follow any of the below methods to get the same:

  1. On the DigitalOcean Cloud Control panel go to the Droplets page, click the name of the Droplet, then select Networking from the side navigation and you can check the private IP address and netmask from there.

  2. Use the commands below in the Droplet::

Command to get the private IPv4 address of the specified network interface
  • curl http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address
Command to get the netmask of the specified network interface
  • curl http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/netmask

For more detail have a look into the link::

https://developers.digitalocean.com/documentation/metadata/#interface-ipv4-index
https://www.ultratools.com/tools/netMask

Hope this helps! Let me know if you have any other questions.

edited by MattIPv4

Many OpenVPN subnets use 10.8.x.x range. It’s straight from DigitalOcean’s OpenVPN Setup tutorial, so please don’t introduce this IP range to private networking, as it would get conflicted with assigned VPN client IPs.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!