Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to set up a default MX record for subdomains ?


MX record set for to
MX record for to

Is there a way I can make sure that mails sent to would be sent to without having to define a MX record for the sub2 subdomain ?

Kind regards,

share|improve this question

migrated from Dec 8 '10 at 20:18

This question came from our site for computer enthusiasts and power users.

up vote 4 down vote accepted

Note that e-mail forwarding doesn't happen via DNS records, it happens in the mail server. Based on my testing, you are going to need to create an MX record in the sub-domain when you you create that zone, assuming that you have other zone information. A wild-card MX record in the parent zone will be hidden by the zone. But maybe you are ok with this, if you don't need any records other than MX in the sub-zones.

As I said, that MX record isn't going to cause mail servers to cause e-mail to to be rewritten to go to, it will just cause the e-mail for to go to the mail server that you specify in the MX record.

The mail server will also need to be configured to handle mail for In postfix, to make this happen automatically, it will depend somewhat on what your exact configuration is for e-mail delivery (if you are using local system accounts, or the virtual delivery agent, or a transport), but in general regex maps will be able to help. For example you could use a regex map as your virtual_maps or local_recipient_maps and then list a record like:

/^(.+)@.+\.example\.com$/    $

You will also need to set up the domains as Postfix virtual domains, though via regex maps you will probably be able to make this configuration static (not requiring updates for every new sub-domain you create).

share|improve this answer
Thank you, that helps me a lot. – Veynom Dec 7 '10 at 14:01
So if I don't have admin access to the mail server (i.e. mail sever for very typical for shared hosting setup), does that means will be impossible to forward to – Antony Mar 7 '12 at 4:04

There is no one answer fits all, and you will probably get a better answer on ServerFault (Voting to move).

This really depends on the DNS server that you are using. If it allows wildcard queries, you can try setting a MX record for * inside the object... Do not create an actual domain object for the subdomain.

However, the downside to this is all queries - sub2 or subx will all result in the same record being done.

As for the second part of your question, this comes down to the mail server, typically having forwarders is easy (once MX records are set up and resolves), but you usually need to manually set them up.

share|improve this answer
In my testing, creating an MX record for * causes it to also respond with A records for names, and if I add an A record for a name, the MX record gets hidden by this name. – Sean Reifschneider Dec 7 '10 at 13:44
@Sean Reifschneider, as I said, different DNS servers will behave differently. – William Hilsum Dec 7 '10 at 16:38
@Wil: Yeah, that could be... I tested on a recent BIND. – Sean Reifschneider Dec 7 '10 at 19:33

Yes you can have separate MX records for a subdomain so that mail for subdomain address such as is handles by a different mail server than the main domain.

As has been said you can't forward mail with an MX record that is done by the mail server. You could either use mail forwarding or have mail both addresses delivered to the same mailbox.

You won't get any mail to the subdomain without an MX records for it, although most control panels will add a default record when you create the subdomain.

share|improve this answer

On Godaddy, I can do this.

For example, set in's DNS Manager. Add MX (Mail Exchanger) record:

Priority: 0 Host: email Points to: email server

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.