I have two outgoing connections, pointing to different ISPs, on a gateway, in front of small-ish LAN.

IPs addresses are as follows:

ISP 1:

  • network:
  • gateway ip:
  • client ip: (eth1)

ISP 2:

  • network:
  • gateway ip:
  • client ip: (eth2)


  • network:
  • gateway ip: (eth0)

Few LAN clients, with IPs in range

So, essentially, gateway has IPs,, and on 3 NICs.

Default route on gateway is set to dev eth1.

Right now, I have one routing table consisting of following entries, named isp2:

  • network dev eth0
  • network dev eth2
  • default route dev eth2

I use that isp2 in MANGLE rules to redirect some traffic to utilize second outgoing link.

Everything works fine, when I want to redirect traffic that goes OUT, if it will go over primary ISP or over secondary ISP, based on MANGLE table rules.

Question: How do I configure gateway so it would allow inbound connections from second ISP, to be forwarded to clients in LAN, behind gateway? I want to forward traffic incoming on specific ports to specific port of specific clients, but it has to work over non-default route.

Any ideas?

Platform that I use is irrelevant, I'm more interested what needs to be done in order for this to work, but you can write examples as if I were using linux (so iproute2/iptables).

  • You want some machines on your LAN to be reachable from the ISP2 WAN? Do those machines have public ip addresses? NAT perhaps? – d-_-b Jul 8 '10 at 17:06
  • @sims: no. they don't have public IPs, they are NATed. I forgot to mention that. – mr.b Jul 9 '10 at 2:25
  • So you want some machines, say an ftp server, to be accessible from the "internet" via the secondary WAN (your secondary ISP provider)? – d-_-b Jul 9 '10 at 5:06
  • @sims: Yes, that would be a good example. – mr.b Jul 10 '10 at 11:57

You may use rinetd.

For FTP forwarding via ISP2, while ISP1 is the default one.

oneliner config:

the downside: on your FTP log, all connections will appear as coming from

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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