Score:0

How to find Free IP address in a sub range?

cn flag

We are using below command to figure out the IP addresses which are down (which is free IP address to use)

nmap -v -sn -n 192.168.1.0/24 -oG - | awk '/Status: Down/{print $2}'

I wanted to get a subrange within that . For example the above command shows all the free IP address from 192.168.1.1 to 192.168.1.124. [ Note: This is for test automation and we are using static IP addresses. Multiple team members are sharing range of IP addresses but often overstep other's range. So this will help us to decide whether IP is really free at that moment before using it)

But I want to find free IP address within the range of

192.168.1.55 to 192.168.1.65

. How to do it?

cn flag
Free as in not in use AT THE MOMENT, or not in use at all? Because you will NEVER find a system down for the moment. This is why DHCP is generally used, and IPAM is a thing.
cn flag
I understood. But we are using static ip addresses for testing automation. It is not in production environment.
cn flag
Does not matter. In this case I would use DHCP, still, possibly with reserving individual IP by mac so a machine gets the same. Easier to change a setting.
Score:1
cn flag

With nmap you can scan range in a sub-net with this syntax (i.e to scan 192.168.0.1 to 192.168.1.30 only) :

nmap  192.168.0.1-30 

So you should easily be able to adapt it with your command :

nmap -v -sn -n 192.168.1.55-65 -oG - | awk '/Status: Down/{print $2}'
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.