Well, we learned how to configure Sendmail to send to a specific IP address on a per domain basis. Google and it’s business service e-mail is now by default publishing IPv6 addresses for MX records, it’s almost impossible to do a per domain setup. We do not want to disable IPv6 entirely on the server, but Sendmail keeps sending out via IPv6. How the hell do you make it stop! It’s quite simple but just a refresher since this is a configuration that is out of sight and mind. Remember that Sendmail is really two things. A Daemon (the part that listens for incoming mail) and a Client (the part that sends/relays e-mail). Naturally you have the DAEMON settings by default, but not the CLIENT settings. So here we go.
I have only found one forum post regarding the proper solution to this problem. It appears not to be properly documented and possibly this is changed behavior in a recent update. However, it does make sense. Essentially you need to tell the IPv6 stack to use your IPv4 address.
Below the above line add this;
Save the file, make the db files and restart Sendmail.
Now, Sendmail will use IPv4 for it’s CLIENT operations.
More mail servers are now accepted e-mail via IPv6. I have had a dynamically assigned IPv6 block on my Comcast Business account for awhile and I have let Sendmail decide what to use, and about 99.9% of mail is delivered via IPv4. Just recently it appears Comcast has assigned an IPv6 MX record for their mail server. My Sendmail picked this up and now happily attempts to deliver the mail via the IPv6 address. Unfortunately, it is immediately rejected due to the IPv6 address does not have a PTR record. Of course Comcast Business is far behind on assigning IPv6 blocks so there is no way to get a static IPv6 block and a PTR entry.
How do I get Sendmail to deliver to the IPv4 address instead? It’s called the mailertable feature.. You will need this feature enabled in your sendmail.mc file. Most likely it is already enabled.
Now you need to make an entry into the mailertable file with the domain and IPv4 address. In order to get the IPv4 MX address for the domain you can do so by using the host command. We first look up the main domain name to get the MX records. Then lookup the IPv4 address for the MX record. We now have the IPv4 address to where we want to deliver the mail.
[root@superstar ~]# host comcast.net
comcast.net has address 220.127.116.11
comcast.net mail is handled by 5 mx2.comcast.net.
comcast.net mail is handled by 5 mx1.comcast.net.
[root@superstar ~]# host mx1.comcast.net
mx1.comcast.net has address 18.104.22.168
mx1.comcast.net has IPv6 address 2001:558:fe16:1b::15
We now add these lines to our mailertable file.
Don’t forget to issue make to update the db files for Sendmail to see the changes to the mailertable file. And then restart Sendmail. It will now deliver to the specific IPv4 address.
[root@superstar mail]# make
[root@superstar mail]# service sendmail restart
Redirecting to /bin/systemctl restart sendmail.service
You bet there is a catch! If the IPv4 address changes, you will need to manually make the change.
That’s it all there is to this. Sendmail is now delivering to the IPv4 address.