R – question about UNIX dig output

digdnsmx-recordunix

Using the unix dig command, I can get the following MX record:

$ dig +nocmd gmail.com MX +noall +answer

gmail.com.      1868    IN  MX  20 alt2.gmail-smtp-in.l.google.com.
gmail.com.      1868    IN  MX  40 alt4.gmail-smtp-in.l.google.com.
gmail.com.      1868    IN  MX  5 gmail-smtp-in.l.google.com.
gmail.com.      1868    IN  MX  10 alt1.gmail-smtp-in.l.google.com.
gmail.com.      1868    IN  MX  30 alt3.gmail-smtp-in.l.google.com.

My question is, what does the fifth column (20, 40, 5…) mean?

Best Answer

The numbers give the relative preference of the MX records. Lower values are more preferred. See RFC 1035