[CentOS] need help in configuring iptables for smtp traffic

Sun Jan 20 08:54:27 UTC 2008
ankush grover <ankushcentos at gmail.com>

Hi Alain,

Thanks for replying to my question.
>
> My understandin is:
> You are load balancing your outgoing traffic....

Yes, load balancing outgoing traffic
> >
> > route add $smtpserver1 netmask 255.255.255.255 gw $publicip1
> > route add  $publicip1 gw $gw1
>
> You are trying to force the GW for smtpserver1, but ....
>
Yes, we are trying to the force the gateway for smtpserver1 and
smtpserver2 . As both the smtpservers will go through specified ISPs.

> > Some more iptables rules which ban sending mails from different
> > vlans/lans directly to public ips (both 1 and 2)
> > $IPTABLES -A INPUT -p tcp -s $lan1 -d $publicip1 --dport $SMTP -j DROP \
> >
> >
> > $IPTABLES -A INPUT -p tcp -s $lan2 -d $publicip1 --dport $SMTP -j DROP \
> >
> >
> > $IPTABLES -A INPUT -p tcp -s $lan3 -d $publicip1 --dport $SMTP -j DROP \
> >
> >
> > Same rules we have for publicip2.
> >
> > But still we are not able to send emails from the $smtpserver running
> > in the local lan to outside. Our requirement is like this smtpserver1
> > which is running postfix should only send/receive emails through
> > publicip1 and smtpserver2 which is also running postfix should
> > sends/receive mails through publicip2.
> >
> > We are able to receive emails both the public ips on the respective
> > smtp servers but when we are sending emails to outside world it is
> > sometimes going through both the public ips from a single smtp server.
>
> ... it doesn't work.
>
> I had a similar problem.
> I have create rules in the mangle INPUT table to 'mark' packets , for  example:
>
> 0 for packet that must be load balanced
> 1 for packet that must go through first ISP
> 2 .... for the second ISP
>
> Then in my routing rules, I use the mark to use one or another routing table.
>

Can you mail me an example that will be very helpful for me.


Thanks & Regards

Ankush