TonyW TonyW - 11 months ago 41
Linux Question

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

I would expect it to come back with ETH0


You should use this comand :

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

Hope this help !