- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Lan enumeration
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 06:40 AM
тАО03-02-2009 06:40 AM
Lan enumeration
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 07:19 AM
тАО03-02-2009 07:19 AM
Re: Lan enumeration
ifconfig and ethtool do the job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 07:55 AM
тАО03-02-2009 07:55 AM
Re: Lan enumeration
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2009 06:45 AM
тАО03-03-2009 06:45 AM
Re: Lan enumeration
#!/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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 09:36 AM
тАО03-09-2009 09:36 AM
Re: Lan enumeration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 11:51 AM
тАО03-09-2009 11:51 AM