0

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?

3
  • 7
    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.
    – TomTom
    Commented Dec 1, 2021 at 17:33
  • I understood. But we are using static ip addresses for testing automation. It is not in production environment. Commented Dec 2, 2021 at 4:30
  • 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.
    – TomTom
    Commented Dec 2, 2021 at 10:14

1 Answer 1

1

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}'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .