Get multiple network interface gateway address in

2019-08-13 23:00发布

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条回答
Anthone
2楼-- · 2019-08-13 23:27

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

查看更多
登录 后发表回答