Link to home
Start Free TrialLog in
Avatar of reneleisibach
reneleisibachFlag for Switzerland

asked on

How can I check if any IP address is available within a IP range I select ?

How can I check with UNIX, if I can reach any IP address within the range of '12.123.*' ?
The original aim is, if a router can be reached. The above question could lead to an acceptable answer for me.
Thank you in advance for your answer.
Rene
Avatar of John
John
Flag of Canada image

You have to ping the address to see if you can reach it.  "Reach it" means you can ping it. And so that is what you have to do.

You can run a scan with Nmap and that will probably make your job easier.

If these addresses are supplied by your ISP, they will have to tell you what IP addresses they allocated to you.
but of course ANY firewall can block ICMP ECHO responses so it may well be in use but you can not ping it.
Hi,

I guess you mean 12.123.n.n.  

With the main aim to reach the router, assuming the router has an IP address assigned and your UNIX server has an IP address assigned, are these on the same subnet? You can check this in a UNIX shell by using;

ipconfig -a

Open in new window


Do you know of other devices in between these two? Any switch or firewall, are there any security rules you have to adhere to - if so perhaps a network engineer can help with this (I am assuming much I know)

Anyway, you can check if an IP address is available by 'pinging' the address itself, again in a UNIX shell;

ping n.n.n.n

Where n.n.n.n is the IP address you want to check is available.

Cheers, JP.
If you were to run a port scan with nmap against 12.123.x.x two things of note....

1) It would take a long time to scan 65535 hosts
2) Your ISP might see this as an attempted hack attack from your network and disconnect you!

Can you explain what it is you are trying to do in more detail? Why would you want to find all routers in a /16 network?
Avatar of reneleisibach

ASKER

The IP addresses would be under the same subnet.
So it would any adress looking like: 12.123.n.n
So use Nmap and run a scan
To Neilsr:
The original aim is, if a router can be reached.
Well as 12.123.x.x is not a privately owned IP Range and is I believe all inside the scope of addresses managed by AT&T in the US you may well find them knocking on your door if you port scan the full range.

You intend to snoop on every AT&T Customer to see if their router is accessible?
To John Hurst:
What is neap?
To Neilsr:
'12.123.n.n' is just a sample and not the real address. It's within a company network to check our routers.
OK but when asking questions be precise, give as much info as you can about your aim/goals and don't use real world IP's that you don't own.

If questioning about your own internal networks then say so and refer to xxx.xxx.xxx.xxx/24 or however big your internal range is.

This helps to get straight to an answer.

That said...
For your own use on an internal network I would recomend you go to  http://www.advanced-ip-scanner.com/
Simple, quick and detailed network analysis giving you what you need and more.

OR

http://angryip.org/
What is neap?  <-- It is Nmap. Typo on my part and I corrected it.  Nmap is a standard Linux / UNIX scanning tool.
Sorry, links were for windows tools and I remember now you wanted Unix scripts/tools.

If this is for an ongoing monitoring task, can I suguest you have a look at the scripts on http://linuxconfig.org/bash-scripts-to-scan-and-monitor-network

They utilise ping and one will even email you when the address is offline.  You could schedule these to run regularly.

On the other hand if your intention is to monitor properly what is alive and whats not, on your network then I would consider looking at installing something like PRTG on a PC and configuring that to watch over everything.
For up to 10 monitoring sensors it is free, after that, heres a price list :D
http://www.paessler.com/prtg/price_list
As an example of use with PRTG, if you have 10 or less routers to monitor, you can use the free version and have it show a dashboard on a screen of the state of all your routers, have it email to a list of individuals when a router goes offline AND again when it is back online.
We have the network monitor unlimited edition and monitor some 15000 sensors in total. You have visual, audio and email alerts to any event you want that happens on your network.
@Neilsr:
Basically I can use your linux-link http://linuxconfig.org/bash-scripts-to-scan-and-monitor-network.
I think it would work. The script runs through, but I just recognized I cannot use ping within our network.
(There is no response.)
Telnet would be working. If only I could use telnet with the port 9999 in the script './bash_ping_scan.sh'.
How could I arrange it?
Rene
ASKER CERTIFIED SOLUTION
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Neilsr:
I just replaced IP and Port, but this works just fine. Thank you.

$ (echo > /dev/tcp/xxx.xxx.xxx.xxx/9999) >/dev/null 2>&1 \
> && echo "It's up" || echo "It's down"
It's up
$

Open in new window


How can I integrate it in the script http://linuxconfig.org/bash-scripts-to-scan-and-monitor-network?
Ping scan of /16 should take couple of minutes on 1Mbit DSL line...