[ASK] How to check whether ipv4 or ipv6 and ping those IP


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [ASK] How to check whether ipv4 or ipv6 and ping those IP
# 1  
[ASK] How to check whether ipv4 or ipv6 and ping those IP

I have perl script that I use to check and ping a list of ip,
The problem is, I didnt understand how to ping ipv6 on perl,
Could I use Ping::External??And how could I get the ping result (reply or not)?

This is my code
Code:
#!/usr/bin/perl --
use Net::Ping;
use Data::Validate::IP;
use Time::HiRes;
$own       = qx(perl /opt/probing/cekip.pl);
$ownhost   = hostname;
@host      = $ARGV[0];
for ( $x = 1 ; $x <= 49 ; $x++ ) {
    $time = [Time::HiRes::gettimeofday];
    $starttime =
      Time::HiRes::tv_interval( $time, [Time::HiRes::gettimeofday] ) * 1000;
    $ping = Net::Ping->new("icmp");
    $endtime =
      Time::HiRes::tv_interval( $time, [Time::HiRes::gettimeofday] ) * 1000;
    $waktu  = $endtime - $starttime;
    $waktu1 = $waktu1 + $waktu;
    foreach $host2 (@host) {
        if ( is_ipv4($host2) ) {
            unless ( $ping->ping($host2) ) {
                    #print "error:$host", scalar(localtime), "\n";
                $lost = $lost + 1;
            }
            else {

                #print "success:$host", scalar(localtime), "\n";
                $lost    = 0;
                $sent    = $x;
                $receive = $receive + 1;
                if ( $waktu > $max1 ) {
                    $max1 = $waktu;
                    $max = sprintf( "%.2f", $max1 );
                }
                if ( $waktu < $min1 ) {
                    $min1 = $waktu;
                    $min = sprintf( "%.2f", $min1 );
                }
            }
        }
        if ( is_ipv6($host2) ) {
           // Still Blank Here..
            }
        }

Thanks in advance,
Franz

Last edited by franzramadhan; 06-17-2011 at 04:03 AM..
# 2  
Not sure if there is a Net::Ping6... but you can try using AnyEvent::FastPing, it's designed to ping a large range of hosts, but I suppose it could be limited to one. It supports IPv6.
This User Gave Thanks to cjcox For This Post:
# 3  
Thanks for your response,
My question, how could I get the ping result? RTO, Unreachable or reply?
Because I must get it on some log files based on ip addresses
And, what is the function of AnyEvent::Socket ?? Could you explain to me?
Sorry for being too pry of this..

Thanks in advance
Franz
# 4  
I have tried your solution, but it doesnt seem to be running.But I have an idea, to get ping result from ping6 command from linux it self. The problem is, I still dont understand how to grep the ping result from this command, whether reply,request timed out, or destination unreachable? Somebody told me to use regex on perl. But I still confused, what kind of regex that I have to use..
Any solutions??

Thanks in advance,
Franz
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #206
Difficulty: Easy
Exterior Gateway Protocol (EGP) is a modern, widely used, routing protocol.
True or False?

9 More Discussions You Might Find Interesting

1. Solaris

How to assign IPv4 and IPv6 addresses with same interface?

Hello dears how to assign IPv4 and IPv6 addresses with same interface on solaris 10 (1 Reply)
Discussion started by: ttashman
1 Replies

2. Solaris

Ntp between ipv4 and ipv6

Hi, I am looking for a solution to configure ntp between ipv4 ( ntp server ) to ipv6 ( client) . I had google, but lot many sites suggest to have dual stock or tunnaling. my issue is I have client has only ipv6 address ans server has ipv4 address. is it possible to sync time,... (4 Replies)
Discussion started by: naveen.surisett
4 Replies

3. AIX

IPv6/IPv4 Only in AIX

Hi all, I have setup ipv6 in AIX machine using autoconf6 command. I was successfull in doing this. after execution of the command local link address was assigned to one of the interfaces (en1).But I have to setup the following environment as well. 1) Machine with only IPv6 support(IPv4... (0 Replies)
Discussion started by: ard
0 Replies

4. Solaris

ISC DHCP ipv4 and ipv6 options

Hi I am looking to set-up ISC DHCP to support ipv6, and to migrate my existing SUN DHCP ipv4 to ISC, finding the ipv4 options for the SUN DHCP options was ok eg TFTPsrvN = tftp-server-name OptBootF = bootfile-name However if I set up a DHCPv6 does anyone know what the equivalent... (1 Reply)
Discussion started by: eeisken
1 Replies

5. Red Hat

IPv4 and IPv6 Related Question to CentOS VMs

Hello, I was wondering if it would be possible to run two VMs one with services for IPv4 and the other one with services for IPv6. The main physical system would be connected to a IPv6 switch. I think it should be fine but I would like to hear out your comments. (1 Reply)
Discussion started by: svalenciatech
1 Replies

6. Solaris

(Help) IPv6 tunneling over existing IPv4 in Solaris

Hi folks, i hope you'll help me to configure my ipv6 tunnel. First, i create my tunnel in: Hurricane Electric Free IPv6 Tunnel Broker My IP is 83.228.93.34 in HE: ------------------------ Server IPv4 address: 216.66.84.46 Server IPv6 address: 2001:470:1f14:16a::1/64 Client IPv4 address: ... (2 Replies)
Discussion started by: static
2 Replies

7. IP Networking

How to configure Samba 3 for IPv6 operation with Window XP for IPv4

Need help...! I want to configure Samba 3 for IPv6 operation with Window XP for IPv4. I appreciate any guide. Thanks HSV (0 Replies)
Discussion started by: Sovan
0 Replies

8. AIX

convert ipv4 ti ipv6

hello i'm working on AIX 5300-05-03 P520 hacmp 5.4 when connection to the internet is going down , firewall down, my application work verey verey slowly!!! and on the sliffer output i'm got trys of my serevr to do convert from ipv4 ipv6 ( 0.0.2.0 and AAAAAAAA). some one have an idea why... (1 Reply)
Discussion started by: ariec
1 Replies

9. UNIX for Advanced & Expert Users

convert from ipv4 to ipv6

hello i'm working on aix 5300-05-03 hacmp ver 5.4 well my issue is that when firewall (gateway to internet ) goes down my machine start to work very very slowly!!! the output of the sniffer is that on the output card , my machine try to convert ipv4 to ipv6 0.0.2.0 my machine is not configure... (1 Reply)
Discussion started by: ariec
1 Replies

Featured Tech Videos