Enumerating each IP address assigned to network interfaces

后端 未结 4 1378
栀梦
栀梦 2021-01-03 11:10

I think there is no way to enumerate each network interface on my system and their assigned IP address using just sockets. Is this correct?

I mean, in Linux this cou

4条回答
  •  自闭症患者
    2021-01-03 11:42

    On Linux, that information is accessed through NETLINK sockets. See the manual pages for libnetlink(3), netlink(7) and rtnetlink(7).

    A somewhat more portable way of doing this is via ioctl()'s. SIOCGIFCONF is the one you want. See the manual page for netdevice(7). This one works on some other *nixes.

提交回复
热议问题