8

With iptables -L -n -v, you can get the number of times each firewall rule has been applied, which is very useful in debugging. I'd like to know if there's a similar way to find out how many times a network route has been used. I'm mostly asking about Linux and Windows solutions, but any platforms' solutions to this would be interesting.

SaveTheRbtz
  • 5,621
  • 4
  • 29
  • 45
Lee B
  • 3,380
  • 1
  • 17
  • 15

3 Answers3

3

Try

route -neeC

and look at the "Use" column. man route says this is the count of lookups for the route.

Ben Williams
  • 2,318
  • 4
  • 21
  • 17
  • Thanks, this looks useful. I'm not entirely sure that a lookup against a route is the same thing as a final decision to use that route AFTER conducting a lookup. Is this safe to assume? – Lee B Oct 26 '09 at 20:34
  • 3
    Fwiw, this 2009 answer will not work anymore (empty result) on linux >= 3.6 (~2012): [ipv4: Delete routing cache](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=89aef8921bfbac22f00e04f8450f6e447db13e42) – A.B Nov 27 '19 at 19:40
1

I don't know of a way to get this information directly, but it would be relatively straightforward with a set of empty rules in iptables that match up with the rules in the routing table.

womble
  • 95,029
  • 29
  • 173
  • 228
1

FreeBSD:

netstat -rn

Linux:

netstat -rneC

Windows:
I think something can be done via netsh

SaveTheRbtz
  • 5,621
  • 4
  • 29
  • 45