Find active servers in subnet
I needed an org-mode table with a list of all currently used IP addresses in a subnet.
#+BEGIN_SRC bash nmap -sP 10.7.2.0/24 | grep "scan report" | cut -d" " -f5 | sort -V #+END_SRC #+RESULTS: | 10.7.2.1 | | 10.7.2.2 | | 10.7.2.23 |
The nmap command returns for each server 2 lines.
The line with the IP address contains "scan report".
cut
splits the IP address from the line and sort -V
sorts by IP address.To run a command in org-mode you press
C-c C-c
inside the region and answer the security question with y
.