When I use variables to pass IP networks to nmap to simplify what will become a regular task, for some reason nmap doesn’t interpret the /XX for the last subnet mask.
Here are the variables (they’re stored in my .zshrc). Note that each “zone” contains two /24 networks.
zone1="192.168.10.0/24 192.168.20.0/24"
zone2="192.168.50.0/24 192.168.60.0/24"
I pass them to nmap like so
# sudo nmap --options, blah $zone1 $zone2
The error from nmap is:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-04 12:56 CEST
Failed to resolve "192.168.10.0/24 192.168.20.0".
Failed to resolve "192.168.50.0/24 192.168.60.0".
etc...
Note that the second set of IP addresses never sees the /24 mask. For whatever reason it’s cut off. The nmap parser seems to interpret it as something else, removes it and then 192.168.20.0 (for example) is no longer a valid address.
I’ve tried changing the variable declaration in .zshrc from simple apostrophes (”) to double apostrophes (“”). I’ve tried a backslash just before the /24 to prevent incorrect parsing. Nothing works. What’s going on here ?
johnmacward is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.