Hostnames in postfix headers should reflect IP the mail was sent through.. how do I make it happen?

Postfix is listening on several different IPs (not ANY, only two of my four) and I want the mail header to show the hostname of the IP the mail went through, instead it’s all showing my main IP.

I’ve already sorted out how to make postfix bind to only two of my four IPs. In my I added…

localhost:smtp inet n - - - - smtpd -o smtpd_sasl_auth_enable=yes inet n - - - - smtpd -o smtpd_sasl_auth_enable=yes inet n - - - - smtpd -o smtpd_sasl_auth_enable=yes -o

Now it listens on but mail sent through it still shows it’s from It doesn’t look like the second -o is getting picked up. Any ideas?

Running Ubuntu 8.04 LTS with virtualmin 3.703 GPL.

PS: How do you disable the header that shows the sender’s IP? Ideally it’d go in one of the smtpd launch lines so that I can do it on one ip, which only trusted users can log in to thanks to ipfilter.

This is more of a kernel routing issue than a Postfix thing.

The issue you’re seeing is that Internet traffic is going out your default route – which is what shows up as the connecting IP to remote servers.

I don’t know of an easy solution. For a more involved solution, you could always look into setting up some fancy routing with iproute2, which – with some work – would allow you to say “using this routing table if the traffic is coming from this IP, or use that routing table otherwise”.

You might be able to get some ideas from the Linux Advanced Routing Howto:

I’d recommend against testing this on a production server, figure it out on a test box before putting it into production :slight_smile: