Carlos wrote regarding 'Re: [SLE] Relaying.' on Mon, Jan 24 at 20:28:
The Monday 2005-01-24 at 11:33 -0600, Danny Sauer wrote:
You use /etc/postfix/transports for choosing a transport based on destination address, and can specify said destination address either as a full address (user@do.main) or just a domain (do.main or .do.main). You can only select a transport based on the recipient address, though, not the sender address. AFAIK.
I thought so, but I also thought I had heard somewhere that more complex rules could be used. You see, it can also make sense to choose a different transport based on the from address, similarly to what a MUA does.
I think that's sort of something the MUS *should* be doing. The MTA is handed a message with a recipient because the MTA is supposed to be the "next hop" on the way to the destination. Regardless of my opinion on the matter (and how useful it would be to your situation), postfix can't choose a nexthop based on the sender. The transport lookup is only done on the recipient address. If it looked up the sender and the recipient, it would need a way to determine which of the two it should prefer in the event of multiple matches, and that would double the amount of time spent in the trivial-rewrite phase. Now, you could potentially combine some address rewriting filter that, given a sender address, would change the recipient before passing it off to postfix - taking advantage of the user+extension@do.main syntax...
If you want to send to a different relay based on what ISP you're connected through, you'll have to set up a script that changes the default transport (or the whole transport map) each time you connect. What *I* would do in that situation, presuming Carlos wants to be just like me, is to make a transport map for each ISP I connect though, and another transport map that has things that are common to both ISPs. So, I've now got transport, transport_ISP1, and transport_ISP2 in /etc/postfix. Then, in my post-connect script for ISP1, I'd run postconf -e "transport_maps=hash:/etc/postfix/transport,\ hash:/etc/postfix/transport_ISP1" postfix reload and similarly for ISP2. That way, my global transport settings are preserved for both ISPs (/etc/postfix/transport), and the map for per-ISP settings are added depending on who I'm connected through.
Ah, that is in the line of what I was thinking about. I was thinking of having two maps, and symlink the right one to "transport" at connect time, and run postmap and reload. This could be done from the /etc/ppp/ip-up.local script, which is run with root privileges.
I only need to learn the name of the provider there. But the only parameters the script is fed with are:
interface-name tty-device speed local-IP-address remote-IP-address ipparam
Can you switch based on the IP address? Surely their netblocks don't overlap, so you could just use the given IP as a determining factor as to which map you'd use... --Danny,