Get multiple network interface gateway address in linux

送分小仙女□ 提交于 2019-12-11 06:22:15

问题


There are many ways to get the network interfaces IP adresses in GNU/Linux (for example with ioctl calls). And also, default gateway from the routing table is available in C.

But I have 2 network interfaces in 2 different networks. Each of these have unique router IP addresses (gateway addresses). How can I get these addresses? The DHCP offers tells them as well and I'm able to get them with nmcli device list for example. But where is this information stored? The NetworkManager database? I want to reach them from C.


回答1:


Under Linux an IPv4 interface's gateway can be read from /proc/net/route.



来源:https://stackoverflow.com/questions/28321877/get-multiple-network-interface-gateway-address-in-linux

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