I want to forward traffic destined for a specific ip from my internal network via a specific interface. I have two interfaces which are currently load balanced. I need all requests for a certain ip to go out via eth0 otherwise my external ip changes and sessions are dropped.

eg. all requests from to ip on port 443 must go out via interface eth0.

How can I do this with iptables?

  • 1
    You need to provide more information like routing table route -n and interfaces IPs ifconfig and any other relevant config. – Khaled Sep 19 '12 at 6:58
  • is this not a one line iptables config? – shapeshifter Sep 19 '12 at 7:21
  • 1
    I am asking this because there could be no need to do anything at if for example you have the default gateway setup via interface eth0. So, you need to provide more information to get better help. Otherwise, we should start guessing. – Khaled Sep 19 '12 at 7:32

ok in my understanding you would like to route all traffic out on eth1 except traffic from to traffic should go out on eth0. in this case you had to configure policy routing. i answered a question like this last week. have a look at:

How can I route different traffic over different interfaces (routes) by protocol?

  • policy routing is for making routing decisions based on anything aside destination ip address. For destination IP criteria a good old routing fits perfect. – DukeLion Sep 19 '12 at 8:11
  • but in his routing decision source ip and destination port is used to make a routing decision. so i think policy routing is that what he need. – user1008764 Sep 19 '12 at 8:19

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.