Skip to content
Advertisement

Find network interface by IP address – Linux/Bash

I’m wondering how I can query by IP address using sed, and it will show which interface name that is using it.

For example..

ipconfig -a | grep 10.0.0.10

I would expect it to come back with ETH0

Advertisement

Answer

You should use this comand :

ifconfig | grep -B1 "inet addr:10.0.0.10" | awk '$1!="inet" && $1!="--" {print $1}'

Hope this help !

Advertisement