在linux中获取多个网络接口网关地址 [英] Get multiple network interface gateway address in linux

查看:128
本文介绍了在linux中获取多个网络接口网关地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多方法可以在GNU / Linux中获取网络接口IP地址(例如使用ioctl调用)。此外,路由表中的默认网关在C中可用。

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.

但我在2个不同的网络中有2个网络接口。每个都有唯一的路由器IP地址(网关地址)。我怎样才能获得这些地址? DHCP提供也告诉他们,我可以用 nmcli设备列表来获取它们。但是这些信息存储在哪里? NetworkManager数据库?我希望从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.

推荐答案

在Linux下,可以从 /中读取IPv4接口的网关PROC /净/路由

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

这篇关于在linux中获取多个网络接口网关地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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