Skip to contentSkip to conversation

Some one knows how to implement policy routing with iptables?

DISCUSSION Robbert 2 participants 8 messages Aug 26, 2004 – Aug 27, 2004 netfilter

lore
Share & tools
lore

Robbert

author
#0 lore raw

Some one knows how to implement policy routing with iptables? Can I do that ONLY with iptabales?

#1 lore raw
Quoted 2 lines · Robbert

Some one knows how to implement policy routing with iptables? Can I do that ONLY with iptabales?

ROUTE target perhaps.

Regards
Henrik

author
#2 lore raw

Yeah,I have seen the ROUTE target,which is useful to force the use of an interface or a next hop and to change the incoming interface of a packet by options --oif,--iif,--gw.However,are these enough? I mean,something depend on TOS,or something like that? And,how can I use ROUTE target to implements policy routing? Some one give me a sample?
----- Original Message -----

Quoted 6 lines

ROUTE target perhaps.

Regards
Henrik

#3 lore raw
Quoted 1 line · Robbert

Yeah,I have seen the ROUTE target,which is useful to force the use of an interface or a next hop and to change the incoming interface of a packet by options --oif,--iif,--gw.However,are these enough? I mean,something depend on TOS,or something like that?

ROUTE just sets the route this packet should take once you have classified the packet. How you classify packets is of no concern to the ROUTE target.

Quoted 1 line

And,how can I use ROUTE target to implements policy routing? Some one give me a sample?

By building iptables rules assigning different routes to different packets.

But most people do policy routing via the mark and normal route rules. See Linux Advanced Routing documentation references earlier in this thread.

Regards
Henrik

author
#4 lore raw

Thanks a lot!
Does the way to implement policy routing with ROUTE target have some LIMIT? Is it only fit to some certain issues?
And, the normal way ,I mean use iptables mark the packet ,then find the corresponding ip rule, and use the corresponding route table, has some shortage?Any way to make it better?

Regards
Robert
----- Original Message -----
Subject: Re: Some one knows how to implement policy routing with iptables?

Quoted 22 lines · Robbert
Quoted 5 lines

Yeah,I have seen the ROUTE target,which is useful to force the use of an interface or a next hop and to change the incoming interface of a packet by options --oif,--iif,--gw.However,are these enough? I mean,something depend on TOS,or something like that?

ROUTE just sets the route this packet should take once you have classified the packet. How you classify packets is of no concern to the ROUTE target.

Quoted 2 lines

And,how can I use ROUTE target to implements policy routing? Some one give me a sample?

By building iptables rules assigning different routes to different packets.

But most people do policy routing via the mark and normal route rules. See Linux Advanced Routing documentation references earlier in this thread.

Regards
Henrik

#5 lore raw
Quoted 1 line · Robbert

Does the way to implement policy routing with ROUTE target have some LIMIT? Is it only fit to some certain issues?

Not sure, I have never used it, only the mark based policy routing.

Quoted 1 line

And, the normal way ,I mean use iptables mark the packet ,then find the corresponding ip rule, and use the corresponding route table, has some shortage?

It gets rather complex if you need to have many different policies for different cases.

Quoted 1 line

Any way to make it better?

The interactions between ROUTE and the rest of netfilter needs to be investigated a little more to make it behave more normal when you play with the routes.

Regards
Henrik

author
#6 lore raw
In reply to Henrik Nordstrom

And I found the rules iptables added are linear,in fact is a link, and no priority at all.Iptables only match them once,if any.So, if I give these rules some priority, or I arrange them by their priority, do you think that means something? ----- Original Message -----
Subject: Re: Some one knows how to implement policy routing with iptables?

Quoted 22 lines · Robbert
Quoted 5 lines

Yeah,I have seen the ROUTE target,which is useful to force the use of an interface or a next hop and to change the incoming interface of a packet by options --oif,--iif,--gw.However,are these enough? I mean,something depend on TOS,or something like that?

ROUTE just sets the route this packet should take once you have classified the packet. How you classify packets is of no concern to the ROUTE target.

Quoted 2 lines

And,how can I use ROUTE target to implements policy routing? Some one give me a sample?

By building iptables rules assigning different routes to different packets.

But most people do policy routing via the mark and normal route rules. See Linux Advanced Routing documentation references earlier in this thread.

Regards
Henrik

#7 lore raw
Quoted 1 line · Robbert

And I found the rules iptables added are linear,in fact is a link, and no priority at all.Iptables only match them once,if any.So, if I give these rules some priority, or I arrange them by their priority, do you think that means something?

iptables is a table of rules, searched top-down. when using iptables you have to sort your rules according to your priority. There is no automatic sorting of rules by priority and you must manually sort them correctly by rule number.

the same thing applies when using mark based policy routing, where first the iptables rules needs to be correctly sorted then also the routing rules (ip rule ...) needs to be sorted.

Regards
Henrik