Monthly Archives: June 2017

MX Preference

In the previous post, we talked about MX records. When we looked at gmail.com’s MX records, there were numbers before the hostnames. Those numbers are preferences, also known as MX preference.

How’s that for a technically boring term? MX preference means something when the computer is determining which of the records to use as a destination for my email. Let’s look at those results for gmail.com again:

gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.

 

The one with the lowest number has the highest preference. How’s that for a contradictory sentence? But it’s how it works. This means that if I’m sending email to gmail.com, then the first place it’s going to try is the system gmail-smtp-in.l.google.com. If this fails, then it goes to the next in the list by preference, that is, alt2.gmail-smtp-in.l.google.com.

The geniuses (Not Dr. Strange and Ironman!) who designed this knew that people really wanted to get their email. Well, not spam email, but they didn’t consider that. They knew that people really wanted email and it should work, so they made it so what should happen is that the system sending the email should try each in order of MX preference.

Not everyone does it, of course. The Internet is a cooperative and it depends on people doing the ‘right thing’ or an approximation close enough to keep things running. Sometimes you’ll send an email and see a bounce from the mailer-daemon (not a real demon), but if you try again in just a few minutes, it’ll go through.

Either the other domain didn’t have a server up to receive the email or the system didn’t check through the MX preference list like it should have, or there was a real demon in the system. Any one of these could have caused the problem.  Especially the demon, demons are trouble.

Fred the Demon

Fred the Demon

I call mine Fred.

Disclaimer: There are no real demons in the Internet. …I think.

Email and DNS

I get lots of email, some of it I want, some of it I’d rather not see. I’m sure that’s true for everyone with an email address. If I get the email, how does it get there? If I send email to my brother, how does my computer know how to get the email to him? It’s a bit of a complicated process, so we’re going to break it down and start by talking about Email and DNS.

One day, I decide I want to send an email to myfriend@example.com.

Why did I say example.com rather than a domain like gmail.com or hotmail.com? That’s because example.com is a domain that was set aside at the beginning of Internet time so people can use it in examples without referring to existing domains. It’s an example, just like its name.  It’s useful to use it because existing domains have been known to go away or change behavior, but example.com is always that, an example.

Ok, back to the subject at hand!

I’m sending email to myfriend@example.com and my first question is how does my email know where to send it?  My second question is, do I send it to example.com or somewhere else?

The geniuses that set up the Internet originally knew that the owner of a domain wasn’t necessarily the same person that ran the domain. The  domain computerlamp.net is what has this blog and while I own that domain, I don’t run things around here. I let DreamHost (Hi guys!) run this for me. That means that they handle my email, I don’t. All I do is read it.

DNS lets us know this by using the MX record. (MX means ‘mail exchanger’. They skipped the E when they made the acronym.)

The MX record for computerlamp.net is:

computerlamp.net mail is handled by 0 mx2.sub4.homie.mail.dreamhost.com.
computerlamp.net mail is handled by 0 mx1.sub4.homie.mail.dreamhost.com.

I did this using the command host.  Using the -t flag, my command was:

Alpha:~ computerlamp$ host -t MX computerlamp.net

If I wanted to know who handles the email for gmail.com, I’d do:

Alpha:~ computerlamp$ host -t MX gmail.com
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.

I got 5 responses back… with numbers in them! Next time, we’ll talk about what those numbers mean.

Running out of time

In this post, I said that Linux keeps time by counting seconds. So, here’s a good question: Is there a number that Linux can’t count past? I mean, if you sat there and counted, you could keep going and going and going until you fell asleep. Linux doesn’t actually fall asleep, it keeps counting… until it can’t. We’ll call it the ‘Running out of Time’ problem.

It’s not like when the good guy runs out of time trying to stop the bomb and everything explodes.

Time is Running Out

Running out of Time

Your system isn’t going to explode! I promise. It just runs out of ways to keep counting.

Most systems today are 32 bit systems or 64 bit systems. That 32-bit (or 64-bit) refers to several different internal operations of your system. We’re going to talk about what it means in terms of numbers. If your system is a 32 bit system, that means the largest number it can store is 2^32. That’s 4294967296. That looks like a big number, doesn’t it? It seems like it’d take a while to count that high. If your system is a 64 bit system, the largest number it can store is 2^64. That’s 2^32 squared or 4294967296 squared. That’s.. a REALLY big number.

The running out of time problem has to do with 32 bit systems.  On January 19, 2038, the number of seconds from January 1, 1970 is going to be larger than 4294967296.  Your 32 bit system isn’t going to be able to count any higher than that and, well, interesting things will happen, or won’t happen.

Running out of Time

Running out of Time

Your 64-bit system doesn’t have that problem, since it can count so much higher than your 32-bit system.

Is there a solution for this problem? Well, no. There’s a lot of smart people working on it though. Those smart people don’t include Tony Stark or Dr. Strange or even Batman, but they’re going to figure it out. Hopefully before January 19, 2038.

Linux® Time

So let’s talk about Linux® and time again. We’ve talked about the calendar, we’ve talked about the Network Time Protocol, but let’s talk about how Linux® stores it.

Everyone seems to have their own way they want to write the date. In Europe, they like to lis t the date first but in America, they like to list the month first. Some people even like to list the year first. And that’s just the date. Now there’s the time! There is the standard of hour, minute, second, but what if you want to write year, hour, month, minute, day, and then seconds? There’s no reason you shouldn’t, right?

Well, keeping track of all of those choices isn’t something Linux® should have to do. Instead, it keeps time by counting seconds, and you can take those seconds and make them look however you want.

Linux® had to start counting seconds at some point, and they chose to start at January 1, 1970.  That’s weird, right?  Linux® wasn’t released until 1991, why did they choose 1970?

Well, I could spin an awesome story about how that’s the instant the first real computer was turned on, or that Iron Man first turned his suit on, or Batman decreed it to be the start of the new era (or new new era), but that would be wrong. The real story isn’t that it’s the birthday of Unix (the Operating System that Linux® mimics), the real story is that it looked pretty.

Computers used to keep time on the sixteenth of a second. This caused problems, because that meant the computer could only tell time for a couple of years before it couldn’t store it anymore. The decision was made that ‘gee, we should use seconds, that’ll work better’. (There was more discussion about this. Imagine the Avengers and the Justice League trying to agree on something.) Once that decision was made, they said ‘huh. Well, let’s start counting from January 1, 1970. That’s a nice round time. Even though it’s 1972 now, that’ll work great’.

And so that’s what they did, they started counting from January 1, 1970.  All Linux® time is stored like that, it just prints out the pretty time (in the format you want).    Check out the man page for date, it will tell you how.