Default Gateway in C on Linux

前端 未结 3 966
-上瘾入骨i
-上瘾入骨i 2020-12-09 05:21

How do you find the default gateway of a routing table using C on Linux?

I don\'t want to issue a call to the shell or read a file. There are ioctls for adding and

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 06:23

    I think reading /proc/net/route will be your best bet. Would you consider this a "file"?

    The format of /proc/net/route is well-known, and in-memory, so there's no I/O penalty or fear of this changing (i.e. versus reading something from /etc/network/*)

提交回复
热议问题