LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Relay email for specific domains to an external address on a non-standard port (https://www.linuxquestions.org/questions/linux-networking-3/relay-email-for-specific-domains-to-an-external-address-on-a-non-standard-port-50482/)

BaDaBooM 03-18-2003 01:47 PM

Relay email for specific domains to an external address on a non-standard port
 
My goal - I have a Red Hat 7.1 box with a single NIC. I want to it to accept any email for only a couple of specific domains on port 25 from anyone and then relay/forward that email to another computer (preferrably by FQDN) on a different port.

I have had a few suggestions of what to use. I can:

A) use some sort of relay or smart host

or

B) use a port redirector

I would prefer to use option A. We loaded postfix on it but I'm not sure that it can do this or how to configure it to. Also if I do option A, can the domain name of the Linux box be the same as one of the domains it is forwarding for?

If I have to do option B, we also have IPtables loaded on it, but again not sure if it can or how to do it.

Thanks for any help!

peter_robb 03-18-2003 02:40 PM

I would suggest using the 'vitual user' system and a port redirector.

Make some redirects, eg
mail4user1@my.domain redirects to mail4user1@host2.my.domain
You can redirect an entire domain with
@my.domain redirects to @host2.my.domain
Each is a fqdn with a valid dns MX record for each smtp server.
The last server can have any host name so long as it resolves.
The redirect will wrap another address header around the mail which keeps the original address intact.
No local copy is held on the first server.

Then add an iptables rule,
iptables -t nat -I PREROUTING -p tcp --dport 25 -d host2.ip.address -j DNAT --to-destination host2.ip.address:port#
to redirect to the other smtp server.

You'll have to check your RELAYing rules to allow this.

I've done this with Sendmail 'aliases' and 'virtusers' but I don't use Postfix, so the actual commands and files you will need to find for this.

BaDaBooM 03-18-2003 10:40 PM

I keep getting errors with my iptables that look like this:

Try `iptables -h' or 'iptables --help' for more information.
[root@host /root]# iptables -t nat -I PREROUTING -p tcp --dport 25 -d host2.domain.com -j DNAT --to-destination host2.domain.com:2500
/lib/modules/2.4.2-2/kernel/net/ipv4/netfilter/ip_tables.o: init_module: Device or resource busy
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters
/lib/modules/2.4.2-2/kernel/net/ipv4/netfilter/ip_tables.o: insmod /lib/modules/2.4.2-2/kernel/net/ipv4/netfilter/ip_tables.o failed/lib/modules/2.4.2-2/kernel/net/ipv4/netfilter/ip_tables.o: insmod ip_tables failed iptables v1.2.4: can't initialize iptables table `nat': iptables who? (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.


All times are GMT -5. The time now is 05:10 AM.