1

I have a mail server that uses postfix to relay all the outbound mail through Gmail's smtp servers. Now I have another internet provider and this one is through a SOCKS proxy connection.

How can I setup my postfix server to route all its outbound mail traffic to the SOCKS proxy?

Wesley
  • 32,320
  • 9
  • 80
  • 116
nerdhacker
  • 61
  • 2
  • 5
  • 1
    Why would you want to do this? As far as I know, postfix doesn't support SOCKS proxies. Additionally, you really ought to go back and "accept" answers to your previous six questions. Having a "0% accept rate" isn't doing you any favors at the moment. – EEAA Feb 25 '12 at 00:06
  • Ok Sorry, i am just new here, i already accept my questions. – nerdhacker Feb 25 '12 at 01:04
  • I need to do this cause my internet connection is trough a socks proxy server, to be more explicit, i have to do an shh tunnel to another server to gain internet access, then i can setup my apps with socks proxy to 127.0.0.1:1080 to use them, i already know about "tsocks" to socksificate an application that does not supports proxys, or also "proxychains" , but i dont know how (or if is possible) to setup Postfix with them, i just need help on however can be the way to route Postfix outgoing traffic to 127.0.0.1:1080 . Thanks – nerdhacker Feb 25 '12 at 01:14

1 Answers1

4

First off, what situation landed you in such an awkward internet connection scenario? I've seen a lot of messed up configurations, but requiring customers to tunnel all of their traffic to a remote ssh server is absurd. I must say, it sounds like you're perhaps trying to run a server somewhere where you aren't supposed to, or are trying to fly under the radar somehow.

Anyway, why don't you just make another non-dynamic ssh tunnel for the smtp traffic? Something like:

$ ssh user@host -L:2525:remote.smtp.server:25

Then you can have postfix deliver use localhost:2525 as its "smarthost".

This will be much more straightforward than using a dynamic proxy like you're currently trying to do.

EEAA
  • 108,414
  • 18
  • 172
  • 242
  • Ok, this sounds like a great idea. My escenario is like a intermedial dialup server, where customers connect to it to send and recieve mail. Is an akward scenario like you say. But it works good for a lot of people with no internet connection. The new internet connection that i am thinking to use is by a ssh tunnel already. any other suggestion?? – nerdhacker Feb 25 '12 at 05:33
  • And if the remote smtp server needs authentication?? – nerdhacker Feb 25 '12 at 05:36
  • If one goes this route, it's also worth looking at [autossh](http://www.harding.motd.ca/autossh/index.html). Running through autossh will cause the connection to be reestablished should it go down for whatever reason, to the extent that connecting without any interactive input is possible. (So just set up a nonprivileged user, `restrict`ed non-passphrase-protected key pair.) Quoting from the project's web site: *"autossh is a program to start a copy of ssh and monitor it, restarting it as necessary should it die or stop passing traffic. The idea is from rstunnel (Reliable SSH Tunnel)[...]"*. – user Jul 19 '17 at 12:06