用FreeBSD上的IP枚举所有网络接口 [英] Enumerate all network interfaces with IPs on FreeBSD

查看:118
本文介绍了用FreeBSD上的IP枚举所有网络接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要列出计算机上的所有网络接口及其IP,IPv4和IPv6.

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

我可以使用ioctl(SIOCGIFCONF)获得所有具有IPv4 IP的接口,但是我也需要IPv6 IP.

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

在Linux上,这些可以从/proc/net/if_inet6获得,但是在FreeBSD上我可以从哪里得到?

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

推荐答案

getifaddrs(3)提供了可移植的方法来获取网络地址和接口名称.

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

这篇关于用FreeBSD上的IP枚举所有网络接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆