04 - Networking basics - ping, domain names, and secure shell

Back to main page

GUI vs. CLI

GUI. Your windows here and there.
GUI. Your windows here and there.

Never heard of those?

Please do not start a gender war around “multitasking”

CLI
CLI

Your CLI

In Windows, cmd is the most used console. Some people use MobaXterm to use the same commands that they know and love from Linux. Have you ever used Linux?

Ubuntu Linux. This is a GUI, but one of the windows has a CLI.
Ubuntu Linux. This is a GUI, but one of the windows has a CLI.

Open up your Windows cmd:

Now fire up some commands!

ipconfig

…will show you your current private IP address(es).

Basic commands

Let’s try some pings! Pings are “echo requests” for other computers/servers in the network. It is a basic command to test if a given address is currently in use.

Many computers can have “echo replies” disabled thus appearing that their IP is available (but it is not!).

The protocol used in ping is called ICMP

This is the main router in the classroom:

ping 10.207.0.1

This is the big server the classroom:

ping 10.207.0.11

This is a 3D printer in the classroom next door

ping 192.168.2.6

And you can also ping domain names or URLs:

The ping also reveals the “latency”, “connection lag” or round-trip time from your computer to the host (computer) that you are pinging. The more latency, the worse communication. Latency is critical in gaming and autonomous driving, among other.

You (yourself) have a fixed address in 127.0.0.1. This is called the “loopback” address.

ping 127.0.0.1

127.0.0.1 is yourself, but pinging your domain name:

ping localhost

…will also ping yourself!

The two last commands do essentially the same: one of them pings your IP, and the other pings your domain name. When you ping a name, the computer has to resolve the address of that domain name. Much like your telephone resolves 6xxxxxxxx when you ask it to ring “Mom”.

Windows only sends 4 pings. You can make it infinite with -t. Cancel it anytime with CTRL + C. Example:

ping -t www.google.es

Hosts file

The hosts file is a plain text file used to map host names to IP addresses. Copy this address and paste it in Windows Explorer:

C:\Windows\System32\drivers\etc

Now right click in the hosts file and edit it:

You can assign simple names to your devices:

192.168.2.6   impresora3d
10.207.0.11   torrebranca

So when you:

ping torrebranca

…the computer will resolve that the address corresponding torrebranca is, in fact 10.207.0.11. You will actually ping 10.207.0.11.

DNS resolution works with a cache, so when your computer has to resolve the IP for a domain name, it records it in the DNS cache so it doesn’t look it up the next time. You can flush (delete) the DNS cache with this command:

ipconfig /flushdns

The hosts file is meant to be used as your phone contacts app: you keep names for your most used devices (servers, printers…).But it can also be used for malicious purposes. You can block URLs with this trick:

127.0.0.1   instagram.com

This will block instagram.com since 127.0.0.1 is my own IP, so it will redirect Instagram requests to myself

But it won’t take effect inmediately, you have to flush the DNS cache:

ipconfig /flushdns

And then it will work:

Not ping nor anything. Not even browsing:

If you mess the hosts file in the router, everyone will suffer the consequences, unless they use a different DNS server.

Video - Simple PING commands

Hi there! In this short video I'm going to show you how you can do a few useful things with the ping command to test your Internet connection. Start by going to your windows search tool and type in CMD or the “command prompt”. Once your command prompt is open you will use the ping command “P” “I” “N” “G” and let's say we're maybe having some internet connectivity ________ (1) with a browser so let's type in a domain name, say, yahoo.com so we've got ping <space> yahoo.com. We're getting replies back so that's good. but what if we weren’t? what if we were pinging (…).

I'll ________ (2) do one that's wrong. Doing ping yahoo.coma. And what you see sometimes is “request timeout”. When you see “request timeout “what it means is it it's trying to reach the address that it's looked up but it's not making it. So either the website is down or you don't have a good connection out to it. Now you could have what's ________ (3) as a DNS issue meaning that you might have a connection the internet but your dns is having ________ (4) so you can try pinging directly to an IP address out on the Internet. A real common one that people use is 8.8.8.8 which is Google's DNS server. So like in that last example we're pinging yahoo.coma didn't work but yeah pinging 8.8.8.8 ________ (5) work. It means I have a connection the Internet. I might just be having some kind of a domain name issue or a DNS issue. Now this helps prove our connection to the internet and our connection to DNS but if you want to bring this back a little closer to home you can also use it to check ________ (6) connections.

Before you do that you kind of need to know what your network topology is and you can do that ________ (7) quick by doing an ipconfig (…) and hit enter and you'll get a lot of ________ (8) so you need to scroll up a little bit and you're looking for your local area network connection or your “Ethernet adapter” right here and it looks like I'm assigned address of 192.168.1.2, my gateway is 192.168.1.1. Most of the time, specially small networks, your gateway usually is your router address so I could ping to see if I can reach my router… and I'm getting two replies back. Say, I ping something fictitious like 192.168.1.8 I think it's not being used… okay so you see how I'm pinging something but I'm not getting replies back, I'm getting the “request timeout”. So that's an indication that either I don't have a connection to that device or that device is offline or somehow ________ (9) to me. Okay? so the ping command can be helpful to find out if you can reach the DNS by pinging DNS names I mean by pinging “Internet domain names”. You can also ping internet IP addresses and you can also paying local area network addresses to check connectivity. Thanks for watching.




Volver al índice