Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have sendmail running in a RHEL box. We have two public IP address configured in the same box, one for SAP app and other for Sendmail. First interface will be used for SAP and second for Sendmail. I have binded the Sendmail daemon on secondary NIC, but when I send out a mail, traffic is getting initiated via the primary NIC and connection is getting refused as port 25 is blocked for the this NIC in the firewall.

Can someone please help me out to resolve this? Should I make changes in Sendmail's config to route SMTP traffic via secondary NIC, or should I play with IPtables to get this done? I need some ideas.

Thanks in advance for the reply.


As requested:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
xxx.x.x.32 U     0      0        0 eth1 U     0      0        0 eth0         xx.x.x.33         UG    0      0        0 eth1
share|improve this question
What is your routing table? ip route show or route -en – Ulrich Dangel Jun 27 '12 at 10:06
route -n O/P Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface xxx.x.x.32 U 0 0 0 eth1 U 0 0 0 eth0 xxx.x.x.33 UG 0 0 0 eth1 – Prem Jun 27 '12 at 10:26
This is a little bit unreadable but it seems that eth0 has no default route so you can only send mails via eth1 – Ulrich Dangel Jun 27 '12 at 10:30
Which interface do you want sendmail to use? – bahamat Jun 27 '12 at 19:28

ip route get $(gethostip -d $NEXTSMTPHOP) should show the interface that will be used for your outbound traffic. Binding an interface will only influence the listen-address for inbound traffic.

So you need to setup routing in a way that your next SMTP-HOP (hopefully a static IP) is going out through your desired interface.

share|improve this answer

I believe you will need to use marking in iptables to choose routes based on the port. The only documentation I have seen on doing this is the Shorewall multiple ISP documentation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.