Reading Route Table on FreeBSD

I am porting an application from Linux to FreeBSD that needs to look at the network route table (β€œroute” on Linux or β€œnetstat -r” on FreeBSD).

On Linux, the application simply reads / proc / net / route and / proc / net / inet6_route.

What is the best way to do this programmatically on FreeBSD?

+6
source share
2 answers

This is described on the man route (4) page. Basically, you read() and write() a PF_ROUTE socket . You can look at the source / sbin / route for an example.

+3
source

I don't know the answer, but maybe you can see how "netstat" does this on FreeBSD, for starters.

+2
source

Source: https://habr.com/ru/post/898544/


All Articles