Let's talk about testing and troubleshooting the network. The most useful utility for testing and troubleshooting 1
network connectivity issues is ping. Ping works by sending ICMP Echo Request packets to the specified 2
destination IP and waits for a reply. 3
When the destination receives an echo request packet, it will respond back with an ICMP echo reply. 4
Ping is also available on Mac and Windows, but with other options. 5
The basic syntax for the ping command is ping 6
some options and the destination IP or domain name. 7
If you run ping without any options, it will send echo request packets continuously until you stop it 8
by pressing ctrl + c: ; for example ping ubuntu 9
.com 10
It's sending echo request packets continuously. 11
I'm stopping it. 12
Let's take a closer look at the output. 13
The ping command has resolved the domain into an address, this one. 14
So the public IP address of Ubuntu.com is 91.189.91.44 15
Maybe you wonder why are you seeing this name 16
elvira.canonical.com and the the ip address between parentheses? If that IP address belongs to 17
ubuntu.com 18
what's with the other domain name? 19
The answer is that an IP address can be set to multiple different domain names and ping performs 20
reverse DNS resolution asking the DNS server configured on the system, what's the domain of the IP. 21
The DNS server responses back with one domain, which is different from Ubuntu.com. 22
It's this one! If you want to prevent ping from doing reverse DNS look up add the - n option. 23
And we see that the destination is reachable because it's responding back. If you ping an IP address 24
which is down, you'll get back 25
no response, like this. 26
It's not responding because it's unreachable. 27
I'm stopping it by pressing ctr+c. To specify the number of echo request packets to be sent before 28
ping will exit, use the -c option, followed by the number of the packets, for example, ping 29
-c 4 ubuntu.com. 30
It will send four packets. 31
Let's take a look at a line! 32
64 bytes is the packet size; icmp_seq=1 is the number of the packet. 33
You can use this to detect issues with bad routing. 34
For example, getting back packets 1, 2, 3, 4and 5 would mean each packet is taking a different 35
route. 36
Basically, you want these to go in order, although you cannot control it. 37
ttl is the Time to Live Value in the received packets. 38
This is normally the number of hops or routers between the source and the destination. 39
The ping time, measured in milliseconds, is the round trip time or RTT needed for the packet to reach 40
the remote host and for the response to return to the sender; and less is better. 41
And some guidelines! 42
A time 43
less than 30 is excellent. 44
30 to 50 milliseconds is average, but still OK. 45
50 to 100 milliseconds is somehow slow and the value greater than 100 means a slow response 46
and probably you cannot run real time applications like voice or video over IP. 47
Let's see some other options! By default ping waits 1 sec before sending the next packet. We can 48
change this interval using the -i option: 49
So ping -i 0.4 -c 5 50
and the destination, google.com. 51
It's sending the package faster, only the super user may set this interval to values less than zero point 52
two seconds. 53
An unprivileged user is not allowed to send packets so fast. 54
But route is allowed. 55
If you only want to get a summary, use the -q like this. 56
It's only displaying a summary. 57
0% packet loss. 58
You can also discover the path a packet takes by sending pings with incrementing ttl values. When a router 59
receives a packet with a TTL value of 1 it will discard the packet and notify the source 60
with an ICMP time exceeded packet. 61
So using a TTL value of 1 means discovering the first router towards destination: 62
Let's see what is the first router towards ubuntu.com so ping-t1 -c3 63
I'm sending 3 packets -n, I do not want a reverse DNS lookup and the destination ubuntu.com. 64
And this is the first router; let's find out the second router. 65
This is the second router; it's a router with a private IP address, so it's probably a router 66
inside the service provider's network. 67
This is the third router; 68
The fourth router towards destination and so on. 69
Probably it's already outside my service provider's network. Ping is a complex command with lots of options. 70
Take a look at its man page. 71
There are so many options. 72
Now, let me show you an easy and quick way to troubleshoot connectivity issues. 73
If there are any connectivity issues, follow these steps: first ping the default gateway of the lan. 74
So router -n 75
I want to see the default gateway and I'm pinging it. 76
If ping is not working, then you have a problem in your own lan, maybe you are not authenticated 77
to the wireless access point, 78
if you use a wireless connection, you don't have the correct IP address set 79
or maybe the router is not correctly configured. 80
If it's working, go to the second step. 81
Ping a public IP address on the Internet! Take something stable, like the public DNS server of Google, 82
which is 8.8.8.8, or the public DNS server of cloudflare, which is 83
1.1 84
.1 85
.1 86
It's working and the other IP address 87
And it's working! 88
If it doesn't work, then there's an Internet connectivity issue; you can check if your router is 89
properly configured or you can even call your service provider and make a complaint. If the router is 90
properly configured, probably 91
the problem is not yours. 92
If it's working go to the third step. 93
Ping an Internet domain, something that's stable, like a Google.com. 94
If it's not working, then you have a DNS issue. 95
Check that you are using the correct DNS server and there is nothing that's filtering the packets and 96
so on; probably if there's a configuration error related to DNS on your site or maybe the DNS server is 97
down. You can change it to 8. 98
8.8.8 the Google public DNS server and try again. 99
The troubleshooting process is considered to be a complex one, and many aspects can get into the equation. 100
The steps I've shown you are in most cases appropriate for home or small networks.