Reading the Routing Tables
brian at Awfulhak.org
Tue Jan 16 00:01:29 GMT 2001
Take a look at src/usr.sbin/ppp/route.c - it goes through the routing
table doing various nasty things using sysctl() - without privileges.
Specifically, route_Show() is a good example of how to do what
netstat does in a reasonably sane way.
Of course you need uid 0 to change anything....
> Thanks for the earlier tips. I've now got a solution from
> our own Ports Tree.
> There is a port called 'zebra' in the 'net' category.
> Zebra is an intelligent router application.
> And of course it runs on Linux, Solaris and all the BSDs.
> So it was simply a case of seeing how the Zerba developer
> managed to read the Routing Table on this wide range of
> platforms, and specifically how they read it on FreeBSD
> and how they read it on Linux.
> And just as you suggested earlier, FreeBSD uses the
> sysctl net.route.dump
> However, it seems this is an internal sysctl which is why
> it does not show up with the sysctl command from userland.
> Anyway, thanks for the tips.
Brian <brian at Awfulhak.org> <brian@[uk.]FreeBSD.org>
Don't _EVER_ lose your sense of humour !
More information about the Ukfreebsd