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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JohnBusiness Consultant (Owner)Commented:
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.
Neil RussellTechnical Development LeadCommented:
but of course ANY firewall can block ICMP ECHO responses so it may well be in use but you can not ping it.
John PopeIT ConsultantCommented:

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.
Thriving as a woman in IT

The IT workforce is diversifying, but the gender gap in tech remains very real. Overcoming stereotypes, and the glass ceiling is important not only for individual women working in the field but for the industry as a whole. Here are eight things women in IT do to succeed.

Neil RussellTechnical Development LeadCommented:
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?
reneleisibachAuthor Commented:
The IP addresses would be under the same subnet.
So it would any adress looking like: 12.123.n.n
JohnBusiness Consultant (Owner)Commented:
So use Nmap and run a scan
reneleisibachAuthor Commented:
To Neilsr:
The original aim is, if a router can be reached.
Neil RussellTechnical Development LeadCommented:
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?
reneleisibachAuthor Commented:
To John Hurst:
What is neap?
reneleisibachAuthor Commented:
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.
Neil RussellTechnical Development LeadCommented:
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 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
Simple, quick and detailed network analysis giving you what you need and more.

JohnBusiness Consultant (Owner)Commented:
What is neap?  <-- It is Nmap. Typo on my part and I corrected it.  Nmap is a standard Linux / UNIX scanning tool.
Neil RussellTechnical Development LeadCommented:
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

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
Neil RussellTechnical Development LeadCommented:
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.
reneleisibachAuthor Commented:
Basically I can use your linux-link
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 './'.
How could I arrange it?
Neil RussellTechnical Development LeadCommented:
without knowing your exact unix variant and whats installed.... Try this at a prompt

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

If the host is listening on port 9999 then it should say "Its up" els say "Its down"

Try please in a bash shell

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
reneleisibachAuthor Commented:
I just replaced IP and Port, but this works just fine. Thank you.

$ (echo > /dev/tcp/ >/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
Ping scan of /16 should take couple of minutes on 1Mbit DSL line...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.