Question

Can I get route gateway information for an interface (programmingly) using getifaddrs() or some other way?

Was it helpful?

Solution

Yes you can. See the manual page for route(4).

OTHER TIPS

You can use sysctl() to dump routing information. In the MIB, the first value has to be set to CTL_NET and the second to AF_ROUTE.

If availabel (as it's freebsd) you could read out /proc/net/route.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top