Linux getting all network interface names

前端 未结 6 1948
傲寒
傲寒 2020-12-01 08:30

I need to collect all the interface names, even the ones that aren\'t up at the moment. Like ifconfig -a.

getifaddrs() is iterating through

6条回答
  •  旧时难觅i
    2020-12-01 08:57

    You are on the right track (it is getifaddrs). It returns each interface once per family, so you get eth0 for ipv4 and one for ipv6. If you just want each interface once you will have to uniq the output yourself.

提交回复
热议问题