If you do a query, using dig on the mail exchange server for google.com you're going to want to do a dig on google.com.
You don't know who is the authority domain for Google, so we can try one of our route servers.
Let's try g.rootservers.net and I'm looking for the mail exchange record.
riaan@debian:~> dig google.com g.rootservers.net MX ; <<>> DiG 9.2.2 <<>> \ google.com g.rootservers.net MX ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, \ status: NOERROR, id: 47512 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, \ AUTHORITY: 4, ADDITIONAL: 4 ;; QUESTION SECTION: ;google.com. IN A ;; ANSWER SECTION: google.com. 300 IN A 216.239.39.99 google.com. 300 IN A 216.239.37.99 google.com. 300 IN A 216.239.57.99 ;; AUTHORITY SECTION: google.com. 259531 IN NS ns1.google.com. google.com. 259531 IN NS ns2.google.com. google.com. 259531 IN NS ns3.google.com. google.com. 259531 IN NS ns4.google.com. ;; ADDITIONAL SECTION: ns1.google.com. 278491 IN A 216.239.32.10 ns2.google.com. 291023 IN A 216.239.34.10 ns3.google.com. 291023 IN A 216.239.36.10 ns4.google.com. 291023 IN A 216.239.38.10 ;; Query time: 1191 msec ;; SERVER: 196.14.187.146#53(196.14.187.146) ;; WHEN: Thu Mar 11 11:04:41 2004 ;; MSG SIZE rcvd: 222 ;; Warning: ID mismatch: expected ID 27547, got 47512 ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: \ NOERROR, id: 27547 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, \ ADDITIONAL: 0 ;; QUESTION SECTION: ;g.rootservers.net. IN MX ;; AUTHORITY SECTION: rootservers.net. 2529 IN SOA \ ns1.mydomain.com. hostmaster.rootservers.net. ;; Query time: 816 msec ;; SERVER: 196.14.187.146#53(196.14.187.146) ;; WHEN: Thu Mar 11 11:04:48 2004 ;; MSG SIZE rcvd: 98 riaan@debian:~> |
If we're trying to look for the mail exchanger for google.com we could use a dig command querying one of the top-level domain servers, which would hopefully give us back the name servers for google.com.
In fact there are 4 name servers for google.com, so we can choose one of them such as: ns2.google.com, and ask the authority. We'll get back that there are these 4 SMTP servers or Google and they are SMTP1,2,3, and 4.
If you can mail to somebody at google.com you can choose one of those mail exchange server's to send mail to.
riaan@debian:~> dig mail.google.com \ ns2.google.com MX ; <<>> DiG 9.2.2 <<>> \ mail.google.com ns2.google.com MX ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, \ status: NXDOMAIN, id: 20162 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, \ AUTHORITY: 1, ADDITIONAL: 0 ;; QUESTION SECTION: ;mail.google.com. IN A ;; AUTHORITY SECTION: google.com. 60 IN SOA \ ns1.google.com. dns-admin.google.com. ;; Query time: 311 msec ;; SERVER: 196.14.187.146#53(196.14.187.146) ;; WHEN: Thu Mar 11 11:08:55 2004 ;; MSG SIZE rcvd: 93 ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, \ status: NOERROR, id: 30079 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, \ AUTHORITY: 4, ADDITIONAL: 7 ;; QUESTION SECTION: ;ns2.google.com. IN MX ;; ANSWER SECTION: ns2.google.com. 86400 IN MX \ 40 smtp3.google.com. ns2.google.com. 86400 IN MX \ 10 smtp1.google.com. ns2.google.com. 86400 IN MX \ 20 smtp2.google.com. ;; AUTHORITY SECTION: google.com. 263506 IN NS \ ns1.google.com. google.com. 263506 IN NS \ ns2.google.com. google.com. 263506 IN NS \ ns3.google.com. google.com. 263506 IN NS \ ns4.google.com. ;; ADDITIONAL SECTION: smtp3.google.com. 60 IN A \ 216.239.57.26 smtp1.google.com. 1037 IN A \ 216.239.57.25 smtp2.google.com. 297 IN A \ 216.239.37.25 ns1.google.com. 90282 IN A \ 216.239.32.10 ns2.google.com. 90282 IN A \ 216.239.34.10 ns3.google.com. 90282 IN A \ 216.239.36.10 ns4.google.com. 90282 IN A \ 216.239.38.10 ;; Query time: 440 msec ;; SERVER: 196.14.187.146#53(196.14.187.146) ;; WHEN: Thu Mar 11 11:08:55 2004 ;; MSG SIZE rcvd: 292 riaan@debian:~> |
Now if I said I'd give you an IP address, 196.7.138.125 and I ask you to what name that translates into you can use a dig -x to reverse search
riaan@debian:~> dig -x 196.7.138.126 ; <<>> DiG 9.2.2 <<>> -x \ 196.7.138.126 ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, \ status: NXDOMAIN, id: 9001 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, \ ADDITIONAL: 0 ;; QUESTION SECTION: ;126.138.7.196.in-addr.arpa. IN PTR ;; AUTHORITY SECTION: 138.7.196.in-addr.arpa. 10789 IN SOA \ ns1.iafrica.com. dns-admin.iafrica.com. 873 ;; Query time: 10 msec ;; SERVER: 196.14.187.146#53(196.14.187.146) ;; WHEN: Thu Mar 11 11:14:27 2004 ;; MSG SIZE rcvd: 105 |