From the computer of: rotten
(1 recipe)
Created: Dec 02, 2004
Of course you can grab the MAC addresses for your interfaces with "ifconfig -a" as root on Solaris 8. However if you want to get them as a regular user use arp.
Here is a script to do it for you:
#!/bin/ksh
# Quick script by rotten to report the MAC addresses on the server.
PATH=$PATH:/usr/sbin; export PATH
hostname=`hostname`
# We are only interested in devices that are configured on boot.
for nic in `ls /etc/hostname.*`
do
# Get the device name.
nicbit=`echo $nic | cut -d. -f2`
# This doesn't work very well on IPMP hosts where there is all sorts
# of extra garbage in the hostname file:
#nichost=`cat /etc/hostname.$nicbit`
# So instead we glean the IP address for the interface from ifconfig:
nicip=`ifconfig $nicbit | grep inet | awk '{ print $2 }'`
# Then we grab the first hostname from /etc/hosts with that IP address.
# It had better be in /etc/hosts - local interfaces are usually there and
# not stashed off box in a name service...
nichost=`grep $nicip /etc/hosts | grep -v "^#" | head -1 | awk '{ print $2 }'`
# There seems to be the occaisional case where the IP is not in /etc/hosts,
# but set directly in /etc/hostname.xxx.
# In this case the arp table probably lists the interface by IP rather than
# hostname.
if [[ -z $nichost ]]
then
nichost=$nicip
fi
# This line is just to see if we are doing ok so far.
#printf "DEBUG --> nicbit=%s\tnicip=%s\tnichost=%s\n" $nicbit $nicip $nichost
# Now we snag the MAC address from the arp table.
macbit=`arp -a | grep $nichost | head -1 | awk '{ print $5 }'`
# And neatly format the results. The "...." are so that the columns line up
# without too much white space.
printf "%s\t%s\t.... %s \n" $hostname $nicbit $macbit
done
# Isn't Solaris fun?
Subscribe to the Tech-Recipes Newsletter
You can get tips like this delivered in your email every week!
We will never, ever sell your email address or spam you.
2 Recipe comments: View comments
Get MAC address without root by Anonymous
Re: Get MAC address without root by VeyronMick
Related recipes:
Change the subnet mask of an interface
Configure interface automatically with DHCP
Simple Solaris IP Multipathing
Solaris 10: set subnet mask in zone
Create a virtual interface in Solaris
Remove a virtual interface in Solaris
Setting Solaris Network Tunable Parameters
Check hme ethernet link speed, duplex, and status in Solaris
Add a default route
View the routing table in Solaris
Sponsored links
Login
Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.Search
Tech Recipes
· Home
· Mac OS X
· Solaris
· Windows
· Programming
· UNIX
· Cisco
· MySQL
· Google
· Instant messaging
· Add recipes
· Leave feedback
· Recommend us
· RSS Syndication
Hot recipes
Make XP look like Windows Vista / Longhorn for free!
XP: Small, Free Way to Use and Mount Images (ISO files) Without Burning Them
SMS through E-Mail: Cingular, Nextel, Sprint, T-Mobile, Verizon, Virgin Mobile
Vista: Should I Install 64-bit or 32-bit Version? (x64 vs x86)
How Do I Use or Open Bin, Cue, or ISO Files?
MySpace Hack: View Pictures and Comments on a Private Profile
Hacks to Beat Rapidshare Download Limits and Waiting Time
MySpacé: Hack to Download Any Song on Mysapcé
Who's Online
There are currently, 1913 guest(s) and 0 member(s) that are online.
You are Anonymous user. You can register for free by clicking here
Information
Wish to advertise with us?
All logos and trademarks in this site are property of their respective owner. The comments and forum posts are property of their posters, all the rest © 2003-2007 by QD Ideas, LLC.
Users of this site are legally bound by the Terms and conditions and Disclaimer. Do not use this web site if you do not agree with these policies.
The members, admins, and authors of this website respect your privacy.
Page Generation: 0.87 Seconds
Thu Aug 28 21:09:01 2008