Enumerate all network interfaces with IPs on FreeBSD

落花浮王杯 提交于 2019-12-02 07:18:50

问题


My application needs to list all network interafaces on a machine and their IPs, IPv4 and IPv6.

I can get all interfaces with IPv4 IPs using ioctl(SIOCGIFCONF), but I need the IPv6 IPs, too.

On Linux, those can get gotten from /proc/net/if_inet6, but where would I get them on FreeBSD ?


回答1:


getifaddrs(3) provides portable way to get network addresses and interface names.



来源:https://stackoverflow.com/questions/7629164/enumerate-all-network-interfaces-with-ips-on-freebsd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!