Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I configure a persistent ip rule on Linux (specifically Redhat based distros)? Is there no built in method? Is my only option adding to /etc/rc.d/rc.local or creating my own rc.d script?

Edit: For clarification I am not referring to iptables but the ip tool (which I don't think a lot of people are familiar with). In any case, the rule I am trying to persist is added with the following command:

# ip rule add fwmark 1 lookup 100
# ip rule
32765: from all fwmark 0x1 lookup 100

The only reference I've found to doing this is from Novell: http://www.novell.com/support/viewContent.do?externalId=7008874&sliceId=1 which recommends creating an rc.d script

share|improve this question
Can you share the IP rule you'd like to persist? –  ewwhite Apr 5 '12 at 18:34
Rule is ip rule add fwmark 1 lookup 100 –  brent Apr 5 '12 at 18:50
add comment

2 Answers

up vote 8 down vote accepted

As is customary I stumble upon the answer to my own problem shortly after asking :) Found an answer at http://grokbase.com/t/centos/centos/099bmc07mq/persisting-iproute2-routes-and-rules

On Redhat 5+ the /etc/sysconfig/network-scripts/ifup-routes script handles rules-* files. Relevant code below:

# Routing rules
if [ -n "$2" -a "$2" != "$1" ]; then
    FILES="$FILES /etc/sysconfig/network-scripts/rule-$2"

for file in $FILES; do
   if [ -f "$file" ]; then
       { cat "$file" ; echo ; } | while read line; do
           if [[ ! "$line" =~ $MATCH ]]; then
           /sbin/ip rule add $line
share|improve this answer
add comment

note if you use priorities in these rule files for any of the rules, you have to use priorities for all the rules. Otherwise, the ones that don't have any priorities all get added to the priority 0 chain.

share|improve this answer
add comment

Your Answer


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.