Network Information =================== Public domain ******************************************************************************** #!/bin/bash ### Network interfaces and IP Addresses ### NICs=$(ifconfig | grep "Link encap:" | awk '{print $1}') for NIC in $NICs; do IP=$(ifconfig $NIC| grep "inet addr:" | awk '{print $2}' | cut -c6-) printf "$NIC : \t $IP \n" done ### Default gateway IP and interface ### GWIP=$(route -n | sed -ne 's,^0.0.0.0,,'p | awk '{print $1}') GWIF=$(route -n | sed -ne 's,^0.0.0.0,,'p | awk '{print $7}') printf "GW : \t $GWIP - ($GWIF) \n" ### DNS servers ### DNSs=$(cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}') for DNS in $DNSs; do printf "DNS : \t $DNS \n" done ******************************************************************************** _BY: Pejman Moghadam_ _TAG: bash, bash-script_ _DATE: 2007-11-27 00:16:43_