Sponsored Content
Top Forums Shell Programming and Scripting Bash script for ping in your own subnet Post 302512458 by Peasant on Sunday 10th of April 2011 12:03:03 PM
Old 04-10-2011
Here is my try, matching output for IP in all interfaces on machine.
Ping it once, if ping failes, print it (or do whatever you want there)

Code:
/inet addr:?[0-9]*.?[0-9]+\.[0-9]+\.[0-9]+/ {
gsub("(addr:|addr:127.0.0.1|.[0-9]*$)","",$2)
split($2,ipz,"\n")
	for ( i in ipz)
		for ( j=1; j <= 255; j++ )
		if (system("ping -c 1 " ipz[i]"."j ) != 0)
		print "ping FAILED on "ipz[i]"."j
}

Save this as pong.awk and run like
Code:
ifconfig | awk -f pong.awk

It will take a while ofcourse to 'scan' everything, if you have multiple interfaces in various subnets.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ping script using Redhat and BAsh

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)
Discussion started by: edkung
11 Replies

2. UNIX for Dummies Questions & Answers

Unix TCP/IP ping to other subnet

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)
Discussion started by: ermingut
2 Replies

3. IP Networking

Migrating existing Subnet to a new subnet and changing ip addresses in UNIX

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)
Discussion started by: johnmarsh
0 Replies

4. UNIX for Dummies Questions & Answers

Ping bash script to file

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)
Discussion started by: asenav1
5 Replies

5. Linux

Ping check failed from Nagios master server on windows hosts in the same subnet

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)
Discussion started by: lovesaikrishna
2 Replies

6. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

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)
Discussion started by: madhudeva
4 Replies

7. Solaris

Guest LDOMS on same subnet cant ping eachother

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)
Discussion started by: selectstar
9 Replies

8. Shell Programming and Scripting

How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

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)
Discussion started by: mail2rias
1 Replies

9. Shell Programming and Scripting

How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

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)
Discussion started by: mail2rias
1 Replies

10. IP Networking

Loop in /24 Subnet, No ping beyond .1 and .2

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)
Discussion started by: Bashed
0 Replies
FETCH(9)						   BSD Kernel Developer's Manual						  FETCH(9)

NAME
fetch, fubyte, fuibyte, fuiword, fulong, fuulong, fuword -- fetch data from user-space SYNOPSIS
#include <sys/types.h> #include <sys/time.h> #include <sys/systm.h> #include <sys/resourcevar.h> int fubyte(const user_addr_t addr); int fuibyte(const user_addr_t addr); int fuiword(user_addr_t addr); int64_t fulong(user_addr_t addr); uint64_t fuulong(user_addr_t addr); int fuword(user_addr_t addr); DESCRIPTION
The fetch functions are designed to copy small amounts of data from user-space. The fetch routines provide the following functionality: fubyte() Fetches a byte of data from the user-space address addr. fuibyte() Fetches a byte of data from the user-space address addr. This function is safe to call during an interrupt context. fuiword() Fetches a word of data from the user-space address addr. This function is safe to call during an interrupt context. fulong() Fetches a long word of data from the user-space address addr. fuulong() Fetches a unsigned long word of data from the user-space address addr. fuword() Fetches a word of data from the user-space address addr. RETURN VALUES
The fetch functions return the data fetched or -1 on failure. SEE ALSO
copy(9), store(9) BSD
December 16, 2004 BSD
All times are GMT -4. The time now is 10:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy