I am testing the handling of mail bouncing. When I send a test email to a bad domain, for example: [email protected], I get the following error in my log:

SYSERR(root): blahblahfail.org.mydomain.org. config error: mail loops back to me (MX problem?)

It seems that if dns fails on the destination domain, sendmail will append my domain to the bad domain.

Why does this happen? And should I expect mail to bounce if the domain is bad? The Unknown-user @ good-domains type of bounces do work for me.

Possible relevant sendmail config lines:


Notes: I have tried removing the always_add_domain Feature. I have my domains listed in /etc/mail/local_host/names

  • Sounds like you are missing a final dot in your Sendmail config; or perhaps the recipient domain's MX record is missing the final dot. In DNS zone files, you need example.com. with a trailing dot to make it absolute; just example.com is relative.
    – tripleee
    Feb 3, 2013 at 17:12
  • 1
    I think the problem is that there was a wildcard in my dns A records. I discovered that if I ssh to a bad.domainname, it resolves to my own ip address. That led me to believe this isn't a sendmail problem, but a dns type problem. Seems if a hostname doesn't resolve, then my system appends my domainname to the unresolveable domainname. With a wildcard in the dns, that crazy domainname resolves to my ip address. Feb 4, 2013 at 17:14

2 Answers 2


see this question

This was not a sendmail problem. It was caused by a wildcard (*) in my dns A records.

I don't know why, but if a name doesn't get resolved, then my domain gets appended to the name, then the dns lookup resolves to my ip address because of the wildcard.

This effects mail, curl, ssh.

If I ssh to badbadfailfail.com, I ssh back to my ip.

I'm removing the wildcard in the dns records.

Adding this into /etc/resolv.conf also works:

search .
  • Adding search . to the resolv.conf appears to do the trick on its own
    – alt
    Jan 27, 2014 at 20:24

Been doing this on both BSD/SYSTEM 5 systems for 20 years +

edit /etc/nsswitch.conf

hosts:          files myhostname dns
networks:       files

edit /etc/hostname

#your hostname.domainname ns1.local localhost.local ns1 localhost

thats it, don't get creative here. keep the loopback to localhost as as well, you don't you'll break stuff here depending on your 'nix ns1.local localhost.local ns1 localhost

edit your sendmail.cf -- yes I know what it says, but I'm right go ahead

Fw/etc/mail/local-host-names %[^\#]
Cwns1 # your hostname alone
Dj$w.local # your domainname alone

Edit your file that you tell sendmail to check for relay, or hosts that will use sendmail.Name it however you want to so long as it matches the cf i.e. /etc/mail/local-host-names -- that is the default for sendmail latest I think

localhost  # Depending on your flavour of 'nix, BSD/SYSTEM 5, you NEED  
#this or you'll break something trying to fix a "small" problem
localhost.local # Same as above, I compile code all the time that calls 
#the loopback or

iptables, way too much to cover here however there are front ends, not so much. Written with the knowledge of whoever wrote them, I write code also. Lets ensure we allow port 25, our local network, 53 UDP IF DNS cache server, and 931 to our loopback unless we want to break our other critical services.

ACCEPT     all  --             
DROP       all  --              ctstate INVALID
ACCEPT     all  --              ctstate RELATED,ESTABLISHED
ACCEPT     all  --           
DROP       icmp --              icmptype 8 ctstate NEW
LOG        icmp --              icmptype 8 ctstate NEW LOG flags 0 level 4
ACCEPT     udp  --              udp dpt:53
ACCEPT     udp  --              udp dpt:123
ACCEPT     udp  --              udp dpt:931
DROP       udp  --             
LOG        udp  --              LOG flags 0 level 4
DROP       tcp  --             
LOG        tcp  --              LOG flags 0 level 4
DROP       all  --             
LOG        all  --              LOG flags 0 level 4

Example above depends very much on YOUR configuration, network (I'm, figure this out on your own because this is NOT a "quid pro quo". I have a PIX in front of me and other "stuff" on my network. Delete localhost.local or your loopback at your own risk -- lots of OS folks hard code this into mandatory services I've seen other answers that will have you do away with this, don't do that.

# /etc/hosts ns1.local localhost.local localhost ns1.local localhost.local  ns1 localhost

Alright, let's restart everything and NO, no reboot we are 'nix sysadmins only thing that won't work is uname -a until we reload the kernel, can't do that from the command line. Become root or sudo whatever you are comfortable with. New guys stick to sudo for your own good.

service hostname restart
ifdown eth0
/etc/init.d/sendmail stop
iptables -F
iptables -nL # should be clean, no rulez
ifup eth0
iptables-restore "file" # wherever you told iptables to 
#iptables-save > "file" to write. Me, well 
#iptables-save > /etc/fw/iptables.rulez
iptables-restore /etc/fw/iptables.rulez # Thats me, pay attention 
#here or get whacked, firewalls are important and why we use 'nix
service hostname stop
service hostname start
/etc/init.d/sendmail start
hostname # should be hostname alone i.e. ns1
hostname -f # full host.domainname i.e. host.domainname for me it's ns1.local
service hostname status
/etc/init.d/sendmail start # tail -f /var/log/syslog or /var/log/messages
iptables-restore /etc/fw/iptables.rulez
tail -f /var/log/syslog or /var/log/messages # Again, depends on your 'nix

In closing I likely missed a step or two, off the top of my head do this and everything will work. Want to become very smart, forget forums and man or info you'll get smart a lot faster than forums. May take all night, but invaluable experience trust that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .