Kudithipudi.Org

May 22, 2009

HOW TO : Find which interface a particular IP address is configured on

Filed under: HOWTO,Linux,Programming,Technology — Vinay @ 3:28 pm

There are a ton of scripts to find how many IP addresses  are configured on a system, but I could not find one, whic would show me which particular network interface an IP address was configured on. Here is a one liner, that will give you this information in Linux

/sbin/ifconfig | grep -B1 10.10.10.10 | awk '{if (NR==1) print $1}'

The same script can be changes a bit to support other operating systems too. Essentially, I am doing a grep (search) of the output of ifconfig, which shows all the network information on the system for a particular IP. At the same time, I am using the -B1 option, which will show the line above the matching line. Finally, I am piping this to awk and printing the first row in the first column.

1 Comment »

  1. не уверена что это так) хотя спасиб

    Comment by Xashered — May 22, 2009 @ 4:22 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress