TonyW TonyW - 4 years ago 146
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

Answer Source

You should use this comand :

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

Hope this help !

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download