I want to create a bash script to ping IP-adresses. It must first ask me the beginnen IP, then the ending IP like: 192.168.100.1 - 192.168.100.255.
When nothing is filled in, then it must find my subnet and ping that, like when my ip is 192.168.100.6, it must ping from 192.168.100.1 - 192.168.100.255.
Yes I do have a script where the IP is already filled in, but not one, which knows in which subnet you are, to ping all of the IP adresses there...
I use the script below to see my own IP from bash script:
It will show your IP. If my IP is something like 192.168.1.5, it has to ping every addres in the 192.168.1.* segment.
This script must also ping every address when I am also in a different segment like 192.1.1.*
How can I accomplish that?
---------- Post updated at 06:55 AM ---------- Previous update was at 06:18 AM ----------
The above will only grep the whole ip. I want to grep 192.168.1.
Only the first 3 adresses. The last one will be filled in by a sequence {1..255}
The question is how to grep the first 3 numbers. now it is 192.168.1 but on a different subnet it could be something like 10.1.1.*
Last edited by Scott; 04-11-2011 at 08:52 AM..
Reason: Code tags
You're assuming it's a 24-bit subnet. That's usually a good assumption with a local address like 192.168.x.x. But there's no reason it couldn't be a 16-bit or 26-bit or other size subnet (16-bit or larger for 192.168).
The Genmask column of the netstat -nr command output reveals the size of the netmask. A 24-bit subnet is shown as 255.255.255.0. A 27-bit subnet would be 255.255.255.224. Both are legitimate.
You're assuming it's a 24-bit subnet. That's usually a good assumption with a local address like 192.168.x.x. But there's no reason it couldn't be a 16-bit or 26-bit or other size subnet (16-bit or larger for 192.168).
Yhat's why you can use the IP command to get information about address - mask, i.e:ip addr show eth0returns me
You can then tail/grep/sed/awk or what you can to get what you need (in this example, the mask has 28 bits).
You can also try ip route list which gives other useful information.
All those commands can be used to get info to ping the whole subnet.
Last edited by frans; 04-10-2011 at 02:53 PM..
Reason: added info aboute ip route
Running 3650 switch. I have this odd issue where I cannot get 4 new Centos 7 boxes pinging out on public IPs (nor pinging in), only gateway .1 and first public IP .2
This is what I see, which doesn't look normal. How do I fix this?
The server itself is configured fine (Centos 7)
# cat... (0 Replies)
Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway.
For example:
Input:
./subnetter.sh 192.168.0.0/24 3 Output:
192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway... (1 Reply)
Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway.
For example:
Input:
./subnetter.sh 192.168.0.0/24 3 Output:
192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway... (1 Reply)
Hi all,
New to this forum.
I have just been reading through a historical thread about some issues with IPMP.
Some tips from "Peasant" where very useful. Please see below
"Just couple of more hints regarding VM.
For VDS, use one VDS - one guest LDOM, don't put everything in primary-vds.... (9 Replies)
HI,
I have a file serverlist in that all host names are placed.
i have written a small script
#./testping
#! /bin/bash
for i in `cat serverlist`
do
ping $i >> output.txt
done
so now it creates a file output.txt till here fine..
now each time i run this script the output file... (4 Replies)
Hello All,
We have added a windows host and its config files to Nagios master server and wanted to do a ping check alone at the moment however, the nagios master server identifies the host in its GUI and immediately disappears can anyone let me know the right approach to this one, We want to... (2 Replies)
Hello:
I have this script:
#!/bin/bash
#for loop
for ip in `cat ips`
do
ping $ip | grep "is alive">>pingtestlog
done
And its working properly with this input:
ericadm@amxcruas1> cat ips
10.196.60.4
10.196.61.210
10.196.62.73
10.196.61.152 (5 Replies)
Hi,
My project needs to migrate the existing Subnet (255.255.255.0) to a new subnet and change the ipaddresses (currently C class). How can I do that. I need some information.
John (0 Replies)
I have Digital UNIX V4.0B (Rev. 564) on alpha machine.
I'm trying to acces network in subnet (192.168.1.x).
Ip on Alpha comp. is from 192.168.3.X subnet. My default gateway on this network is 192.168.3.1 and it working OK from other machines. This machine is visible from same subnet... (2 Replies)
Alright, I have being checking out various posting here trying to hack together something for a friend
Needed:
A script that can run in cron doing:
ping of several hosts and notifying via email when they are unavailable.
I am not going to post my non working messes (I am a basic... (11 Replies)