Hot answers tagged

26

DUP means duplicate packet. From man ping: Duplicate and Damaged Packets ping will report duplicate and damaged packets. Duplicate packets should never occur, and seem to be caused by inappropriate link-level retransmissions. Duplicates may occur in many situations and are rarely (if ever) a good sign, although the presence of low ...


24

When you run: ping -q -c 1 google.com > /dev/null && echo online || echo offline You are essentially only redirecting the output of Stream 1 (i.e. stdout) to /dev/null. This is fine when you want to redirect the output that is produced by the normal execution of a program. However, in case you also wish to redirect the output caused by all the ...


24

A ping cannot be 0 bytes on Linux, Windows or any other platform that claims to be able to send pings. At the very least the packet must contain an IP header and a non-malformed no-trick-playing ping will also include an ICMP header, which is 8 bytes long. It is possible that windows differs in how they output the bytes received. Linux tells you the size ...


18

Sending a single packet and waiting for a response is going to be one of the fastest possible ways, and ping is a fine way to do that. In fact, depending on your use case, I'd argue that it's too fast, since it doesn't really tell you if the system is actually doing anything useful, just that the kernel's network subsystem is alive and configured. But ...


17

It means the reply packet is a duplicate. Each ICMP packet sent out to pint a host has a sequence number that is returned with the response. Sometimes you'll actually get more than one reply. This is usually caused by faulty networks. Wireless networks often rely on re-sending packets if they don't get proper verification, and if the first one actually ...


16

From the ping manpage (emphasis mine): When the specified number of packets have been sent (and received) or if the program is terminated with a SIGINT, a brief summary is displayed. Shorter current statistics can be obtained without termination of process with signal SIGQUIT. So this will work if you're fine with your stats being slightly less ...


15

You might have better luck using the tool arping instead. The tool ping works at the layer 3 level of the OSI model, whereas arping works at layer 2. You still need to know the IP of the system however with this tool. There are 2 versions of it, the standard one included with most Unixes (Alexey Kuznetsov's) is the version that can only deal with IP ...


14

Short answer: You can't do with a normal user. Long answer: To be able to mark packets, you need to be a root user, or at least a user with the SO_MARK capability(needs to be set as root): SO_MARK at socket(7): SO_MARK (since Linux 2.6.25) Set the mark for each packet sent through this socket (similar to the netfilter MARK target ...


13

What the RFC says is actually immaterial here. The RFC specifies what goes on at the DNS level, but that's moot if ping doesn't make a DNS query in the first place. When ping receives an all-numeric argument, it interprets it as an IP address. IPv4 addresses are technically 32-bit numbers. They are almost always written in dot-decimal notation, so-called “...


13

ping needs root so it can open a socket in raw mode. That's literally the first thing it does when it starts up: icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); socket_errno = errno; That's the only thing it needs root for, so like many programs, it immediately drops its privilege level back to your normal user account: uid = getuid(); if (setuid(...


10

The hostname command outputs the hostname of the system from the systems local hostname configuration (could be /etc/hostname or /proc/sys/kernel/hostname or other depending on OS). The command ping -c 1 <hostname> is going to perform a lookup through the libc resolver (which may or may not be DNS. e.g., /etc/hosts is not DNS) of the <hostname> ...


9

Like this: nc -z hostname 22 > /dev/null echo $? If it's 0 then it's available. If it's 1 then it's not.


9

That's how the ping command works. You can control it using the count switch, -c. Example $ ping -c 2 skinner PING skinner.bubba.net (192.168.1.3) 56(84) bytes of data. 64 bytes from skinner.bubba.net (192.168.1.3): icmp_req=1 ttl=64 time=1.00 ms 64 bytes from skinner.bubba.net (192.168.1.3): icmp_req=2 ttl=64 time=1.13 ms --- skinner.bubba.net ping ...


9

You need to redirect both standard output (> or 1>) and standard error (2>): ping -q -c 1 google.com > /dev/null 2>/dev/null && echo online || echo offline or, redirect one to the other: ping -q -c 1 google.com > /dev/null 2>&1 && echo online || echo offline


9

The "Network is not reachable" message is printed to stderr, not stdout, so it isn't captured by your substitution ($(ping ...)). You need to redirect stderr to stdout when running ping, not when you log: print_and_log "$(ping -c10 "$i" 2>&1)"


9

What's your layer 2 transmission medium? Ethernet? There's no way to have an ethernet frame shorter than 64 bytes, regardless of what it carries. So, even if you could send a ICMP ping with 0 bytes of payload, your ethernet card will pad the frame up to 64 bytes for transmission. @Casey showed that your theoretical minimum is 28 bytes, but ethernet will ...


8

$ ping -q -c 1 google.com > /dev/null 2>&1 && echo online || echo offline Examples $ ping -q -c 1 google.com > /dev/null 2>&1 && echo online || echo offline online $ ping -q -c 1 googleadf.com > /dev/null 2>&1 && echo online || echo offline offline Speeding up ping Depending on your ping ...


7

while ! ping -W 1 -c 4 www.google.com >& /dev/null || ! ping -W 1 -c 4 www.yahoo.com >& /dev/null; do sleep 600 done Though I'd just test connectivity to an IP address; 8.8.8.8 is Google's public DNS server (it has very high availability). Testing whether DNS works is unreliable anyway because the entry may be in the cache. while ! ...


7

According to the Solaris 11 network interfaces manual in chapter 8 “Configuring an IP Interface”: ipadm create-addr -T static -a 10.0.11.10/24 eth0/staticip eth0 is the name of the Ethernet interface (listed by ipadm show-if). staticip is a name that you can choose.


7

That server might be configured not to answer ICMP packages, or its router is set-up not to let those through. I remember from the time I was still using Windows XP that you had to explicitly install things in order for the machine to answer ping packages.


7

This isn't really an infinite loop; it's a task that needs to run every ten minutes. As such the task can go into the task scheduler, cron. Run the command crontab -e and add this single line to the bottom of the file: */10 * * * * /path/to/my-command-here Ensure that my-command-here is an executable script (chmod u+x my-command-here) and that its first ...


7

Outgoing ICMP (ping) is probably blocked by your firewall or gateway. That you are able to browse the Internet does not need ICMP (ping) to be working. You also might have a proxy configured which allows you to only surf the web.


6

Well, not exactly... What Wikipedia, and in turn the RFCs say is that since the original RFC 952, which didn't allow leading numerics, you can now have them. ( Per RFC 1123 ) You still can't have all numeric though, which is your problem. Your '6952' isn't a valid hostname, while '6952x' should be fine. But, RFCs aside, I've had problems within the last ...


6

This is what fping was designed for. http://fping.sourceforge.net/ You need to parse the output afterwards instead of relying on a return code, but it is much faster than doing normal ping.


6

echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts - as root. You may need to also use the -b option with ping and it will most likely require root permissions.


6

So here are in one answer a summary of my comments. You have 3 solutions depending on your environment: A. Your Windows host is connected to a network 1- Use "Bridge networking" And select the Windows network interface that is configured under Windows to have network access. Make sure you have no firewall on Ubuntu: sudo iptables -L should give you no ...


6

From man ping: -w deadline Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received. In this case ping does not stop after count packet are sent, it waits either for deadline expire or until count probes are answered or for some error notification from network. -W timeout ...


6

The asterisks you're seeing are servers that your packets are being routed through whom are timing out (5.0+ seconds) and so traceroute defaults to printing the *. NOTE: There's even a warning about this in the traceroute man page. excerpt In the modern network environment the traditional traceroute methods can not be always applicable, because of ...


6

You can use a while loop in a shell script: failed=1 # any number not equal to zero while [ $failed -ne 0 ] do ping -n 8.8.8.8 failed=$? done # after the $? becomes "0" it will get out of the while loop echo "ping succeeded" To stop keep printing the connect: Network is unreachable message you can edit the line with ping like this: ping -n 8.8.8....


6

ping is the way to test whether a host is alive and connected. (If a host is alive but disconnected or slow to respond, you can't distinguish that from its being dead.) Options supported by the ping command vary from system to system. You'll want to ensure that it doesn't loop forever but returns after a few seconds if it didn't receive a reply. With ...



Only top voted, non community-wiki answers of a minimum length are eligible