Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to hide the client IP from emails sent from postfix.

here is an example of what I mean:

Received: from mail.[removed].com (adsl-75-37-61-254.dsl.frs2ca.sbcglobal.net [75.37.61.254])
    (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
    (No client certificate requested)
    by mail.[removed].com (Postfix) with ESMTP id D50C7BF185DD
    for <[removed]@gmail.com>; Thu,  2 Aug 2012 16:14:21 +0900 (JST)
Date: Thu, 02 Aug 2012 07:14:08 +0000

Notice this line (adsl-75-37-61-254.dsl.frs2ca.sbcglobal.net [75.37.61.254])

I want to remove that line from the email.

I've tried doing this:

/etc/postfix/main.cf :

smtp_header_checks = regexp:/etc/postfix/smtp_header_checks

smtp_header_checks :

/^((.*) [(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])])/    IGNORE

But my IP address is still inside of the received part of the email. If I send email off the smtp server locally the IP address becomes localhost.localdomain [127.0.0.1]

How can I remove client IPs from the header?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

In main.cf:

smtp_header_checks = pcre:/etc/postfix/smtp_header_checks

In dynamicmaps.cf:

# Use your real path to dict_pcre.so, below
pcre    /usr/lib/postfix/dict_pcre.so           dict_pcre_open

You should put this in your /etc/postfix/smtp_header_checks:

/^Received: .*/     IGNORE
/^X-Originating-IP:/    IGNORE

Then run

# /etc/init.d/postfix reload
share|improve this answer
    
My ip address is still displayed. I appreciate the efforts. –  Kyle Aug 2 '12 at 7:43
    
It is not necessary to have postfix-pcre. Regexp works the same way. –  Kyle Aug 2 '12 at 7:45
    
Alright. I have made sure pcre was install on the system. I have changed regexp:/etc/postfix/smtp_header_checks to pcre:/.... I have then restarted postfix and monitored maillog for any errors. No errors were displayed. The email still displays my ip. XD Thanks for the efforts, Mike. –  Kyle Aug 2 '12 at 7:51
    
Hmm... I get an error but I found this irbs.net/internet/postfix/0404/1097.html I tested the regex with this postfix.org/pcre_table.5.html using argument: postmap -q "Received: from mail.[removed].com (adsl-75-37-61-254.dsl.frs2ca.sbcglobal.net [75.37.61.254])" pcre:/etc/postfix/smtp_header_checks and the output was IGNORE so it is working. However it is not making changes in the email... Is the field inside main.cf wrong? –  Kyle Aug 2 '12 at 7:57
1  
No worries at all, I actually had them mixed up in my answer too... perhaps contributing to the problem –  Mike Pennington Aug 2 '12 at 8:04

Your Answer

 
discard

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.