plebreak.blogg.se

Advanced ip scanner linux
Advanced ip scanner linux





Windows ( starting since Windows 7, I think ) have started blocking response to ICMP echo requests.How much better does that work ? Not bad, actually, takes a matter of seconds. Now, there's also one single main function which does the looping and calling of pingf. I put the ping and printf into a function, pingf (yes, corny name, I know). Much better performance improvement can be achieved if we spawn several background processes. Quoting here isn't necessary - since we're dealing with numbers only, we don't need to anticipate word-splitting due to having spaces in a variable. This is more of a stylistic change, but it's consistent with how printf works and looks like in a lot of other languages, with quoting "$NUM" variable. The printf command can be rewritten as so: printf "IP %s is up\n" 192.168.0."$NUM" In other words, it's sufficient to do this: if ping -w 1 -q -c 1 192.168.0.$NUM > /dev/null

advanced ip scanner linux

Since we have 256 addresses and we assume 1 second for each address, the script will take about 256/60 = 4.27 minutes.ĭoing a command and then capturing its exit status with $? wasn't really necessary. So we could force ping to time out with -w 1 flag.

advanced ip scanner linux

By default, ping for two RTT, which can vary depending on how congested is your network, and as far as I understand TCP protocol doubles the wait time each time(at least according to this). The script is obviously slow and ping waits for response from the host. Since then I've learned a bit more about shell scripting, and I once I saw this script, I thought it would be a good idea to revisit this answer to add a few improvements. I originally posted this answer in August of 2015.

advanced ip scanner linux

Quick and dirty way, took me about 10 mins to write it, but runtime might be a bit slow,though. What we have here is just while loop, where we set last number in the address, make silent single ping to the address, check if the command succeed or not (and if it did succeed,then host is obviously up ), and printf statement. Nmap would be my #1 choice, but what if you don't have it ? The DIY way would be with a ping script that goes through each possible ip address on the network manually. See the revisited version below for a new and improved script that performs much faster. Note to the reader: Original answer has been posted a while ago and at the time of when I was only learning shell scripting.







Advanced ip scanner linux