Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have the following simple situation: two internet connections via two distinct ethernet NICs, eth0 and eth1, and two APs (I use hostapd, of course) on two distinct wireless cards, wlan0 and wlan1. The two wifi cards have different subnets (192.168.53.0/24, 10.0.15.0/24), and the two ethernet cards are on different subnets (192.168.1.0/24, 10.10.2.0/24).

I would like to keep forwarding completely separate, in other words:

   wlan0 --> eth0
   wlan1 --> eth1

I know how to bind applications to different interfaces, and how to use policy routing. What I do not know is whether I can use iptables to forward as above, or I absolutely need to use Policy Routing to achieve this.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You need policy routing.

Ordinary routing will choose the next-hop address or interface based on the destination address and nothing else. That is, all packets to the same address will use the same route.

Once you use other factors like the inbound interface to influence the routing decision, you are by definition performing policy routing.

netfilter/iptables do have an addon providing a "ROUTE" target to do PBR with netfilter alone, but its adoption, maintenance and testing are poor relative to the typical iproute2 rule-based approach. As even the netfilter maintainers say there,

"Whenever possible, you should use the MARK target together with iproute2 instead of this [iptables] ROUTE target."

share|improve this answer

Your Answer

 
discard

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.