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.
Under Linux an IPv4 interface's gateway can be read from
/proc/net/route
.