Simple shell script to know your Linux systems Interface IP’s

Below is the simple shell script  which tells simply scan all interface in Linux system and tells which interface  have what IP assigned.

#!/bin/bash

ip r l |grep kernel|awk ‘{print $3}’|paste -sd” “|while read line
do
ARRAY=$line

for i  in $ARRAY
do
IPREAD=`ip r l |grep ‘kernel’|grep $i|awk ‘{print $9}’`

echo “Interface:$i having $IPREAD IP assigned”
done

done

Sample Output:

Interface: wlan0   having  192.168.X.X   IP  assigned
Interface: virbr0   having  192.168.X.X   IP assigned

 

 

 

 

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s