Pega IPs de todas interfaces de rede


#!/bin/bash
# Pega IPs de todas interfaces de rede configuradas

echo -e "\nConfiguracoes das placas de rede\n"

# Pega todas as interfaces de rede configuradas
for i in $( ifconfig | sed 's/[ \t].*//;/^\(\)$/d' | sed 's/:$//' ); do

  # Pega configuracoes de cada interface de rede
  IP=$( ifconfig $i | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | sed -n 1p )
  NETMASK=$( ifconfig $i | grep -Eo '([255]{1,3}\.){3}[0-9]{1,3}' )
  echo -e "$i\t\tIP:\t$IP\t\tMASCARA DE REDE:\t$NETMASK"

done

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