Reading the Routing Tables

Dominic Mitchell dom at
Mon Jan 15 09:15:39 GMT 2001

On Sun, Jan 14, 2001 at 04:44:14PM +0000, Roger Hardiman wrote:
> Hi all
> I need to read the IP Routing Table into a userland program
> but it seems I can only read it (from kvm) if I'm root or
> my application is set-user-id and owned by root.
> This is a bit of a problem.
> I need to read the Routing Table in the OpenH323 libraries
> for the H323 VideoPhone Proxy I'm porting.
> But I don't want the library or the proxy to be owned by root if
> possible.
> Linux seems to get around this by reading from /proc/net/route
> but we don't have in FreeBSD.
> Do any of the programmers our there have any ideas?

Could you just read it in from a pipe to "netstat -rn"?  Alternatively,
you write a small program, setgid kmem, which does print out the routing
details (in a more readily usable format than netstat).

Looking at my copy of "Unix Network Programming", there should be a
sysctl to dump the routing table, under net.route.dump.  However, that's
certainly not in my copy of FreeBSD (4.2-STABLE).  It may be worth
looking back through the CVS logs to find that sysctl and add it back


More information about the Ukfreebsd mailing list