Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

What is the significance of the prio option in ip rule add/del command? Does a higher priority for a rule give it preference over other rules in the table?

I saw this piece of code online, without any comments to it. I'm curious to know what it does:

ip rule del prio 32766 from "" dev "" fwmark 0 table main

ip rule del prio 32767 from "" dev "" fwmark 0 table default

ip rule add prio 4294967293UL from "" dev "" fwmark 0 table 1

ip rule add prio 4294967294UL from "" dev "" fwmark 0 table main

ip rule add prio 4294967295UL from "" dev "" fwmark 0 table default
share|improve this question

migrated from Nov 21 '11 at 19:38

This question came from our site for professional and enthusiast programmers.

The priority determines the order in which the rules are checked (from lowest number to highest). The first rule which matches the packet is used.

The maximum priority is 32767 though, so those big priority numbers don't make sense.

share|improve this answer
"The first rule which matches the packet is used." this is not completely correct. The rules are in fact checked in the order specified by priority, but a rule which has its conditions satisfied may in fact not provide a result, and more rules are checked. The prime example of this is when a rule specifies a "lookup" (or "table"), but there is no route in that routing table matching the destination. – Ambroz Bizjak Apr 27 '12 at 21:05

Your Answer


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