Bash script to list all IPs in prefix

后端 未结 11 1568
[愿得一人]
[愿得一人] 2020-12-23 12:23

I\'m trying to create script that I can input a set of prefixes, which will then list all IP addresses within the prefixes (including network/host/broadcast).

An ex

11条回答
  •  礼貌的吻别
    2020-12-23 13:24

    nmap is useful, but an overkill.

    You can use prips instead. Saves you the hassle of grepping out the extra output from nmap and using awk.

    Calling prips 192.168.0.0/23 will print what you need.

    I use the following to skip the network address and broadcast: prips "$subnet" | sed -e '1d; $d'

    Prips also has other useful options, e.g. being able to sample every n-th IP.

    It's available via apt,brew,rpm and as tar.gz.

提交回复
热议问题