question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get List of Available IP for Subnet

See original GitHub issue

Azure CLI recently added this command:

az network vnet list-available-ips -g [resource group] -n [vnet name]

This works great but only seems to return some ip addresses in the VNet.

Can we leverage the jmeshquery --query to specify some ip range or a subnet to narrow this down?

Is your feature request related to a problem? Please describe. Yes, the list-available-ips command doesnt return all available ip’s

For example you may have 192.168.0.0/16 and you may have a bunch of subnets, can we filter to a given subnet, or get all available ip’s from the vnet.

Describe the solution you’d like Option 1 - Possibly use --query to specify the ip range of the subnet or subnet name

Option 2 - Add the same list-available-ips command for az network vnet subnet

If there is a way to do this, maybe we can document it and update the CLI Docs with an example.

Describe alternatives you’ve considered Manually typing random ip’s in a range to see if they are consumed.

Additional context We did this for VNet level but that only returns some of the available ip’s.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
thiDucTrancommented, Jun 2, 2021

we are using this as a workaround

#!/usr/bin/bash

vnet_rg=""
vnet_name=""
subnet_name=""
netmask="24"

max_ip=$((2 ** (32-$netmask)-5))

used_ip=`az network vnet subnet show -g $vnet_rg -n $subnet_name --vnet-name $vnet_name -o json | jq  ".ipConfigurations[].id" | wc -l`

available_ip=$(($max_ip - $used_ip))

echo "There are $available_ip IPs available"
0reactions
necusjzcommented, Jun 30, 2022

Testing blocked by feature Microsoft.Network/AllowMultipleAddressPrefixesOnSubnet registration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert CIDR notation to a list of IP addresses
Convert CIDR notation to a range of IP addresses​​ This tool takes an IP address and CIDR netmask (e.g. 192.168. 1.0/24), and lists...
Read more >
How to Find Available IP Addresses
How to Find Available IP Addresses · 1. Press the “Windows-R” key combination to open the “Run” window. · 2. Type “cmd” (without...
Read more >
How to get a list of all valid IP addresses in a local network?
Type ipconfig (or ifconfig on Linux) at command prompt. This will give you the IP address of your own machine. For example, your...
Read more >
Get a List of All IP Addresses on a LAN | Baeldung on Linux
Before we can scan the network, we need to determine the subnet. Subnetting is the process of dividing a large network into smaller...
Read more >
IP Subnet Calculator - Colocation America
If you're buying a usable block of IPs for your business, it would be tedious to calculate all the things necessary for your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found