retrieving the interface name via ip address

e9hack e9hack at gmail.com
Thu Mar 3 00:28:36 PST 2022


Hi,

it exist the two functions network_get_subnet and network_get_subnet6 in /lib/functions/network.sh. They return the first ip or ip6 address of a given interface. In my case:

root at my-openwrt:~# . /lib/functions/network.sh; network_get_subnet subnet "lan"; echo $subnet; network_get_subnet6 subnet6 "lan"; echo $subnet6
192.168.107.1/24
fec0:0:0:eeee::1/64

Does exist the reverse function too? I would like to get the interface for an ip address, ether for the real address of the interface or for an ip address of the subnet.

Regards,
Hartmut



More information about the openwrt-devel mailing list