Publié le: 2011-02-23

Network scripts

Adresse MAC

#!/bin/bash
MAC=$(ifconfig $1 | grep -Ri $1 -m 1 | awk '{print $5}');
echo "Adresse Mac:" $MAC;

Adresse IP

#!/bin/bash
IP=$(ifconfig $1 | egrep 'inet add?r:' | awk '{print $2}' | cut -d: -f2);
echo "Adresse Mac:" $IP;

Masque réseau

#!/bin/bash
MASK=$(ifconfig $1 | egrep 'inet add?r:' | cut -d: -f4);
echo "Masque réseau:" $MASK;

Serveurs DNS

#!/bin/bash
DNS=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}');
echo "Serveurs DNS:n"$DNS;