Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 03-18-2003, 02:47 PM   #1
LQ Newbie
Registered: Mar 2003
Posts: 5

Rep: Reputation: 0
Question 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


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!
Old 03-18-2003, 03:40 PM   #2
Senior Member
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
I would suggest using the 'vitual user' system and a port redirector.

Make some redirects, eg
mail4user1@my.domain redirects to
You can redirect an entire domain with
@my.domain redirects to
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.

Last edited by peter_robb; 03-18-2003 at 03:44 PM.
Old 03-18-2003, 11:40 PM   #3
LQ Newbie
Registered: Mar 2003
Posts: 5

Original Poster
Rep: Reputation: 0
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 -j DNAT --to-destination
/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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to allow mail relay of specific IP address Stev Linux - Networking 4 03-03-2020 08:24 AM
Blocking mails from specific email addresses/domains in postfix jomy Linux - Networking 1 07-15-2008 09:32 PM
Sendmail Relay-Domains From External Server littlenicker Linux - Networking 3 05-25-2005 12:45 PM
Exim cannot receive email from external address davidas Linux - Software 1 04-23-2004 04:17 AM
Postfix upgrade from 1.x to 2.0.19 can't relay to external domains issinflight Linux - Software 0 04-19-2004 11:42 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:01 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration