1752707 Members
5618 Online
108789 Solutions
New Discussion юеВ

Lan enumeration

 
Piotr Kirklewski
Super Advisor

Lan enumeration

Hi Guys

I need to make a list of all the network devices, their mac addresess and IP addresses.

Could you please tell me what programs are you using to enumerate the network ?

regards

PEter
Jesus is the King
5 REPLIES 5
smatador
Honored Contributor

Re: Lan enumeration

Hi,

ifconfig and ethtool do the job
Fredrik.eriksson
Valued Contributor

Re: Lan enumeration

I believe something like this would print out everything you were searching for :)

It's untested since I don't have a machine to try it on.

#!/bin/bash
IFS="
"
for i in $(ifconfig -a | egrep "^(HWaddr|inet addr)"); do
case $i in
^[a-z])
devname=$(echo $i | awk {'print $1'})
macaddr=$(echo $i | awk {'print $7'})
;;
*)
ipaddr=$(echo $i | awk {'print $3'})
;;
esac
echo "$devname has MAC $macaddr and IP $ipaddr"
done

Best regards
Fredrik eriksson
Fredrik.eriksson
Valued Contributor

Re: Lan enumeration

As said earlier, not properly tested :P

#!/bin/bash
x=0
IFS="
"
for i in $(/sbin/ifconfig -a | egrep "(HWaddr|inet addr|^lo)"); do
array[$x]=$i
let x=x+1
done
IFS=""
x=0
while [ $x -lt ${#array[*]} ]; do
devname=$(echo ${array[$x]} | awk {'print $1'})
macaddr=$(echo ${array[$x]} | awk {'print $5'})

let y=x+1
ipaddr=$(echo ${array[$y]} | awk {'print $2'} | cut -d':' -f2)

echo $ipaddr | egrep "^[0-9]" &> /dev/null
[ $? -eq 0 ] || ipaddr="None"
echo $macaddr | egrep "^[0-9]" &> /dev/null
[ $? -eq 0 ] || macaddr="None"

echo "$devname has MAC $macaddr and IP $ipaddr"
let x=x+2
done

This version works atleast for me :)
Guess it would break if you have some dodgy interface output :)

Best regards
Fredrik Eriksson
Ciro  Iriarte
Valued Contributor

Re: Lan enumeration

You can use nmap (nmap -sP 10.1.1.*) or a front end like cheops-ng if you prefer GUIs
Wilfred Chau_1
Respected Contributor

Re: Lan enumeration

ip addr show