All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roberto Nibali <ratz@drugphish.ch>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] how to remove rules
Date: Thu, 16 Dec 2004 14:58:53 +0000	[thread overview]
Message-ID: <41C1A2AD.5080202@drugphish.ch> (raw)
In-Reply-To: <a0f69e504112302571452545a@mail.gmail.com>

Hi,

>  : I've had the same problem.  I sorta wish there was an "ip rule flush" 
>  : command that would leave only the default rules.

Would be nice.

> I have a function called "flush" which flushes all tables and all rules 
> other than the main routing table.  Here's the "rule" flush portion.  It 
> won't win any points for elegance, but it should get the job done:
> 
>     ip rule show | grep -Ev '^(0|32766|32767):' \
>       | while read PRIO RULE; do
>       ip rule del prio ${PRIO%%:*} $( echo $RULE | sed 's|all|0/0|' )
>     done

This is what I've used in my iproute2 shell library package, maybe it's 
a bit more elegant (only one fork involved). Since we change our local, 
main and default table in our distro to different values I've added a 
KEEP variable. Prepend it to adjust to your settings.

: ${KEEP:="local main default"}
while read prio rule; do
     continue=0
     for keep in ${KEEP}; do
         if [ "${rule//lookup ${keep}/}" != "${rule}" ]; then
             continue=1
         fi
     done
     if [ ${continue} -eq 0 ]; then
         ip rule del prio ${prio%%:*} ${rule//all/0/0}
     fi
done < <(ip rule show)

Best regards,
Roberto Nibali, ratz
-- 
echo 
'[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' | dc
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

      parent reply	other threads:[~2004-12-16 14:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-23 10:57 [LARTC] how to remove rules Askar
2004-11-23 17:48 ` Chris Bennett
2004-11-23 19:30 ` Martin A. Brown
2004-11-23 20:23 ` Chris Bennett
2004-12-16 14:58 ` Roberto Nibali [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41C1A2AD.5080202@drugphish.ch \
    --to=ratz@drugphish.ch \
    --cc=lartc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.