Hide server IP Received: from - SMTP

Migdiradmin

Verified User
Joined
Jan 5, 2020
Messages
158
Hi i use cloudflare to protect one ip server, and i want to use one account in directadmin to user smtp services.

Server A (Cpanel) Apache/PHP
Server B (Directadmin) email

But wen i send one email from Server A with smtp from server B show the IP from server A.

Code:
Received: from serverA.com ([x.x.x.x] helo=localhost) by serverB.com with esmtpsa
  (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from <[email protected]>) id 1jp72Z-0000Xc-Jk for @gmail.com; Sat, 27 Jun 2020 10:22:27 +0100

In the past i use services smtp like namecheap and they dont show the IP from server A.
Anyone have a solution?
 
I have read to add this to exim.conf

remote_smtp:
driver = smtp
headers_remove = Received

But exim fails to start, any clue?
 
It probably fails because you miss the ':' behind the Received header. But it's server B who adds the address of server A. If you are server A, you won't be able to remove your ip address from the headers.
 
This works but removes but removes Received: from entirely and i just want to hide IP from A server in the Received: from.

Code:
#COMMENT#61:
remote_smtp:
  driver = smtp
  headers_remove = Received
  headers_add = "${if def:authenticated_id{X-Authenticated-Id: ${authenticated_id}}}"
  interface = <; ${if exists{/etc/virtual/domainips}{${lookup{$sender_address_domain}lsearch*{/etc/virtual/domainips}}}}
  helo_data = ${if exists{/etc/virtual/helo_data}{${lookup{$sending_ip_address}iplsearch{/etc/virtual/helo_data}{$value}{$primary_hostname}}}{$primary_hostname}}
  hosts_try_chunking =
  hosts_try_fastopen =
.include_if_exists /etc/exim.dkim.conf

Any ideas?
 
The problem is that each server writes a Received header.

So your server writes:
Received from: Client IP

The next server writes:
Received from: Your server IP

So you can only remove the first one, because the second one isn't written by you. You need to relay your email out of a second server which removes previous Received headers, where that second server is an IP you don't mind leaking (maybe it has DDOS protection). This is something I do. All of my outbound mail goes out to a filter server which removes previous Received headers, so the trail back is only as far back as I want it to be.

Here's a tip on how to use a mail relay: https://help.directadmin.com/item.php?id=153

But again, the relay has to be made to remove those headers, it can't just be any relay. Else, it'll just be adding more headers.
 
Last edited:
Hello
Did you find a solution to remove the IP form the header?
Yes, with this.
 
This works but removes but removes Received: from entirely and i just want to hide IP from A server in the Received: from.

Code:
#COMMENT#61:
remote_smtp:
  driver = smtp
  headers_remove = Received
  headers_add = "${if def:authenticated_id{X-Authenticated-Id: ${authenticated_id}}}"
  interface = <; ${if exists{/etc/virtual/domainips}{${lookup{$sender_address_domain}lsearch*{/etc/virtual/domainips}}}}
  helo_data = ${if exists{/etc/virtual/helo_data}{${lookup{$sending_ip_address}iplsearch{/etc/virtual/helo_data}{$value}{$primary_hostname}}}{$primary_hostname}}
  hosts_try_chunking =
  hosts_try_fastopen =
.include_if_exists /etc/exim.dkim.conf

Any ideas?
Where is the location to edit this files?
 
Try /etc/exim.conf but be aware this can be overwritten on the next update.

You might need to set exim.conf update to no in the options.conf in custombuild.
But you won't get other exim.conf updates then either. So be aware of that.
 
Back
Top