I'm completely new to DNS and how it work. Lately I've been getting mail spammed like crazy on one of my domain. I'm not using any mail for this domain and don't need it. I don't want to stop it just locally, is there a way to edit DNS so that this domain won't even receive any email whatsoever? Thanks in advance.
If the domain is not supposed to send or recieve email, it should not have an MX record. Spambots may still try to use the A record to locate it and send email to it.
Consider adding and SPF (Sender Policy Framework) record of the form "v=spf1 -all", which will indicate the domain does not send email. DNS has an SPF record type for this, but many tools still look for a TXT record. This should reduce any backscatter spam if the domain is used to send email.
If the domain truly does not send or accept email, there should be no email servers configured to accept email for it. Ensure that your email server rejects all email sent to recipients in that domain. If you are receiving email for the domain, your email server must be configured to accept email for the domain. This is not a DNS solution, but is part of the solution. You mail server should be configured to accept email only for the domain(s) which should be sending and receiving email.
It is best practice to limit the domains participating in email exchanges. Generally this would be the registered domain. Typically,
example.com would be the email domain while
www.example.com would neither accept nor send email.
You should not do that without the consent of the other party but it is possible to point the MX to a wrong host i.e. one not configured for this domain which will refuse accepting this mail (though I am not sure whether the A record is tried then instead) or to one with a mailserver which just throws everything away. Pointing to a host without a reachable MTA also might result in the sender trying the A record host.
A popular technique is to add an MX record that points to the root domain:
yourdomain.com. IN MX 10 .
There's no A record for the root domain, so this should cause a failure. However, spammers may know about this trick, and ignore this MX record.
Another technique that some use is to point it to
yourdomain.com. IN MX 10 localhost.yourdomain.com. localhost IN A 127.0.0.1
This will cause the sending system to try to send the mail to itself. Again, I wouldn't be surprised if spammers have caught on to this trick as well.