1

Is there a command I can run from the shell that will allow me to see all of the MX records on the server?

We have a dedicated server with cPanel on it. By default, we have all of the routing settings set to Auto. This works great until we have a company with a custom MX record going to a subdomain that's pointed to a different IP address. In that situation cPanel keeps the routing settings to local, when it should be remote.

I need a way to quickly look through all of the MX records on the server (we have over 600 sites) and see which records are not going to the default DOMAIN.com so I can verify that all of those match up with the /etc/remotedomains file.

Thanks!

  • Are they in a single domain, so you can just do a transfer of the domain? (Obviously, this requires your security settings to allow zone transfers). Otherwise, why don't you just read / iterate over the zone files themselves? – Charles Duffy Sep 16 '14 at 16:50
  • There are multiple domains (over 600), meaning that's a lot of files to individually parse through. Maybe if I grep `IN MX` through all of the named files I can accomplish what I want. I'll try that. – Seth Alling Sep 16 '14 at 17:26
  • A script reads through 600 files... should take you far, far less time than writing this question. – Charles Duffy Sep 16 '14 at 17:28
  • True, but I'm a PHP developer who tries to stay out of the server admin stuff as much as possible, so writing the script is hard if you're not really familiar with the language needed to write one or where the zone files are so I can run a script on them. ;) Thanks for your help. – Seth Alling Sep 16 '14 at 17:39
  • *nod*. Where the zone files are is up to your distro's packaging, so there's no single correct answer -- not everyone keeps them in `/var/named`, even though that's common. – Charles Duffy Sep 16 '14 at 17:45

1 Answers1

0

I found it. I just had to enter into the /var/named/ directory and then run the following command to create a file of what I need.

grep -rP "IN\tMX" * >> mxrecords.txt

  • 1
    Why use the `-P` extension and ruin your portability? `grep -r 'IN[[:space:]]+MX'` will work with more grep implementations, and with files formatted with spaces instead of tabs. – Charles Duffy Sep 16 '14 at 17:38
  • See the comment about my lack of command line knowledge. :) I just knew the cPanel files created the DNS zone files with tabs. – Seth Alling Sep 16 '14 at 17:41