Monthly Archives: February 2017

More about Networking, aka Route my Traffic

So we talked about IP addresses, we talked about how to turn a domain name into an IP address… so the next question is, how do we get there from here?  I mean, how does my computer access that domain that I want to see?  Well, it’s called routing or taking a route.

When I leave my house and go to the comic book store, I take a route.  I can go down back roads or main roads or even sneak through back alleys if I’m walking.  I could even take a detour through the Batcave (if I knew where it was) or sneak through Stark Enterprises (If I knew where that was!).

But I’m lazy.  Taking all those detours or back alleys or even back roads is just the long way and I really want to get there as quick as possible.  I want the latest Spiderman, please, or the latest Wonder Woman.  I don’t want to spend all my time getting there.

Well, the Internet works the same way.

When you go from your computer to www.google.com, you send your traffic on a route through the Internet.  That route takes you through various computers with a special tasks, known as routers.  You hop from one router to the next until you reach that magic destination.  Which is kind of why each step is known as a hop.  Think of it as a magical rabbit carrying your information from one computer to the next until he reaches his rabbit hole.  Or don’t, that’s rather silly.

Of course, there’s a command to see those hops.  It’s called traceroute.

You can run this from your command like:

Alpha:~ computerlamp$ traceroute www.google.com
traceroute to www.google.com (172.217.4.164), 30 hops max, 60 byte packets
 1 ip-69-163-160-1.dreamhost.com (69.163.160.1) 2.273 ms 2.246 ms 2.229 ms
 2 pdx1-cr-1.sd.dreamhost.com (66.33.200.2) 0.211 ms pdx1-cr-2.sd.dreamhost.com (66.33.200.3) 0.229 ms 0.268 ms
 3 pdx1-bdr-2.sd.dreamhost.com (66.33.200.1) 0.239 ms pdx1-bdr-1.sd.dreamhost.com (66.33.200.0) 0.234 ms 0.262 ms
 4 pdx1-bdr-1.sd.dreamhost.com (66.33.200.0) 0.248 ms google.nwax.net (198.32.195.34) 5.565 ms pdx1-bdr-1.sd.dreamhost.com (66.33.200.0) 0.215 ms
 5 google.nwax.net (198.32.195.34) 5.589 ms 6.025 ms 108.170.245.114 (108.170.245.114) 5.611 ms
 6 209.85.248.159 (209.85.248.159) 6.152 ms 108.170.245.98 (108.170.245.98) 5.733 ms 66.249.94.201 (66.249.94.201) 6.185 ms
 7 209.85.250.126 (209.85.250.126) 8.912 ms 72.14.238.38 (72.14.238.38) 9.633 ms 209.85.250.126 (209.85.250.126) 8.765 ms
 8 74.125.37.136 (74.125.37.136) 30.852 ms 30.771 ms 209.85.250.126 (209.85.250.126) 8.087 ms
 9 209.85.248.124 (209.85.248.124) 30.571 ms 74.125.37.136 (74.125.37.136) 29.833 ms 209.85.247.0 (209.85.247.0) 29.980 ms
10 108.170.247.129 (108.170.247.129) 31.130 ms 209.85.247.0 (209.85.247.0) 30.637 ms 30.647 ms
11 108.170.247.161 (108.170.247.161) 31.333 ms 31.123 ms 108.170.247.129 (108.170.247.129) 30.494 ms
12 108.170.234.215 (108.170.234.215) 30.513 ms lax28s01-in-f164.1e100.net (172.217.4.164) 30.423 ms 108.170.234.213 (108.170.234.213) 30.562 ms

That’s twelve hops to get there from here!

Or I could use what is called a Looking Glass Utility and do it on a webpage.  Global Crossing has such a Utility.  This lets you see the route from somewhere else, rather than from your computer.

traceroute doesn’t always work.  Sometimes companies block the kind of traffic that traceroute uses.  Try using it to go to www.marvel.com and see what happens!  If you

 

DNS

In the last post we talked about how computers only understand numbers not names, in this post we’ll talk DNS. It’s how the computer knows what number goes with what name without knowing every
possible combination.

IP addresses can also change, so a computer would not only have to keep up with every possible combination but also all of the possible changes every second of every day.  Remember, there’s 4294967296 IP addresses. This translates to ‘a lot of them’. I’m not sure even a superhero could do that without help. Hrm. Maybe Batman or Iron Man could build something.

Now in the old days of the internet, this was possible. It wasn’t that big. Now… it’s that big. I mean, we’re running out of IP addresses and there’s 4294967296 of them.  Since we have no superheroes to solve this, we had to rely on the geniuses that created the whole thing to begin with. They’re the superheroes of the Internet!

Back to what DNS is. It’s a system that takes a name and returns an IP address. When you open your web browser to go to www.google.com, the first action it takes is to find that IP address using DNS. It asks the server known as a name server.   It doesn’t just ask any name server though, it asks the servers known as the roots.

The roots are a collection of name servers that only know where other name servers are.  It’s like a super search engine.  Suppose there’s a search engine that tells you if you need to go to Google or Bing or Yahoo or even Wikipedia to do your search.  You have to go to the super search engine first, then to that engine, then FINALLY to your answer.

In the case of DNS, you go first to the roots (that is, super search engine) who tells you what name servers know the answer for domains that end with com, and then that name server will tell you the name server that knows the answer for google.com.

No one name server knows all, it’s what is called a distributed system. This means if one name server is taken off line, it still works. Unlike the Death Star, that’s a single system. Blow that thing up and there goes the Empire!  Or those droids in Phantom Menace.  They blew up the one ship that controlled all the droids and WHOOPS, there goes all the droids offline!

If you want to find the IP address for www.google.com, there’s a command for that.

Alpha:~ computerlamp$ host www.google.com

Try it out, see what you get!

Networking

Let’s change the pace a little bit, we’ve talked about using the command line to do things, now we’re going to talk about the computer network and IP addresses.  That’s also know as networking.

These days, computers do everything. Planes, trains, automobiles, your house, your phone, everything has computers. Everything is on the network too! You can even buy  light bulbs that you can talk to over a network connection. Isn’t that weird? I can’t wait for my light bulb to message me ‘I’m dying, please replace me.’ I wonder if Batman has network enabled gear yet. Can you imagine his Batmobile sending a message saying ‘My tire is low’. I wonder if it would send that to Alfred instead of Batman…

Anyway, back to the computers doing everything. One important thing to know is that they don’t understand words, they understand numbers. If you tell your phone ‘connect me to the Batmobile’ it won’t understand the word ‘Batmobile’, it has to turn it into a number it will understand. (And if your phone does connect you to the Batmobile, tell me how you did it? I want to talk to it too!)

Those numbers are called IP addresses.  An IP address (also technically called an IPv4 address) is a number between 0 and 4294967296.  Can you imagine having to remember the IP address of your computer if it was just an integer?  2130706433 is an awful number to have to memorize.  Luckily, the geniuses who designed everything came up with dotted quad notation.  It’s a bit mathy (wibble wobble effect here) but instead of memorizing 2130706433, you’d memorize 127.0.0.1.  That’s four numbers to remember with dots in between, which is why they called it dotted quad.

This website has a converter so you can see what the integer is for the IP address of your computer.

But first, you’ve gotta know the IP address of your computer before you can use that website.  There’s a command for that!

Alpha:~ computerlamp$ ip addr show

Try it out and see what you get!

The bashrc file

In this post we made aliases… now we want to save them in a file; bash has such a file called the .bashrc file.  It’s also known as the bash configuration file.

That period before the name is very important, without it it isn’t the right file.  It also means that the filename is hidden from view when you do a ls.  You have to use the ls -a flag in order to see it.

But this post isn’t about ls, it’s about the .bashrc file.  We’re going to use nano, that useful editor we talked about in the last post, to edit the file.

I’ll start with opening the file in nano:

Editing .bashrc with nano

Editing .bashrc with nano

I did this with the command:

Alpha:~ computerlamp$ nano .bashrc

Now I’ll type those two alias commands that I used before.  I aliased more to less and history to whatIdid:

Adding Aliases to the .bashrc file

Adding Aliases to the .bashrc file

And now we save the file:

Saving .bashrc with nano

Saving .bashrc with nano

Well, so now what?  I edited the file, I added those two lines, and saved it… just don’t forget to exit nano when you’re done with control-X!

Once we created the file, we need to use it.  Otherwise, we just saved our aliases in a file to do nothing.

It’s called sourcing  the file.  The command to do it is:

Alpha:~ computerlamp$ . .bashrc

See that dot before the .bashrc?  Be sure to type it.  That’s how bash knows to use its configuration file.  Also, every time you open up a new terminal, you’ll have those aliases.  And you’ll be able to see them with the alias command.

You can also look at what you’ve got aliased by using:

Alpha:~ computerlamp$ cat .bashrc

The output is exactly the same, no matter which one you use.  It looks like:

alias less='more'
alias whatIdid='history'

The .bashrc has other uses aside from aliases, we’ll talk about more in the future.