How do I make qmail-smtpd listen on 2 different ports?
I've tried adding a second line to the supervise run script which would duplicate the tcpserver exec statement but it seems as though the second line doesn't get loaded.
9 Replies
If you (can) run qmail-smptd from inetd you could add a line in /etc/inetd.conf for each port…
OR, setup another config file with the other port specified, and run two instances ?
-Chris
Just as an FYI for anyone else who might have this question, I did the following:
Copy /var/qmail/supervise/qmail-smtpd to /var/qmail/supervise/qmail-smtpd2. Edit the run script located in the qmail-smtpd2 directory (make sure you designate the new port that you want it run on) and the run script located in the log sub-directory.
Create a symbolic link to your new smtpd2 supervisor directory…
ln -s /var/qmail/supervise/qmail-smtpd /service
Edit the qmailctl script (mine is at /usr/bin/qmailctl) and duplicate all qmail-smtpd entries with qmail-smtpd2 entries.
This should get it up and running on seperate ports.
--James
UPDATE: - OK, I got bored (read: I'm avoiding studying for finals) and I went and looked up the syntax to do this with iptables. This works for me, just replace 25 with the port where the service is listeneing now and 2525 with the new port you also want it listening on.
iptables -t nat -A PREROUTING -p tcp --dport 2525 -i eth0 -j REDIRECT --to-ports 25
# iptables -t nat -A PREROUTING -p tcp --dport 2525 -i eth0 -j REDIRECT --to-ports 25
# iptables->save /etc/sysconfig/iptables
# iptables -L -v -n -t nat
Chain PREROUTING (policy ACCEPT 640 packets, 29571 bytes)
pkts bytes target prot opt in out source destination
0 0 REDIRECT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:2525 redir ports 25
Chain POSTROUTING (policy ACCEPT 3441 packets, 140K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 3441 packets, 140K bytes)
pkts bytes target prot opt in out source destination
But if I attempt to connect to port 2525 I get Connection Refused.
–James
–James
nat This table is consulted when a packet that creates
a new connection is encountered. It consists of
three built-ins: PREROUTING (for altering packets
as soon as they come in), OUTPUT (for altering
locally-generated packets before routing), and
POSTROUTING (for altering packets as they are about
to go out).
Locally generated packets will never hit the PREROUTING rule, you'll need to setup a near identical rule using OUTPUT to make it work.
Having the following commands in an iptables file will get the job done:
-A PREROUTING -p tcp -m tcp --dport 2525 -j REDIRECT --to-ports 25
-A OUTPUT -p tcp -m tcp --dport 2525 -j REDIRECT --to-ports 25