For When You Can't Have The Real Thing
[ start | index | login ]
start > perl > convert Hex MAC to decimal OID

convert Hex MAC to decimal OID

Created by dave. Last edited by dave, 9 years and 280 days ago. Viewed 8,832 times. #3
[diff] [history] [edit] [rdf]
labels
attachments

Problem

When you are dealing with MAC addresses, systems like to print them out as hexadecimal numbers:

# arp -an
? (10.0.10.200) at 00:80:F0:56:46:30 [ether] on eth0

...but OID values in SNMP are decimal.

Solution:

I call this script hexmac2decoid

#!/usr/bin/perl

$in=shift @ARGV; @elements=split(/:/,$in); for $element (@elements) { print ".".hex($element); }

Example

# snmpwalk -v 1 -c public procurve1 .1.3.6.1.2.1.17.7.1.2.2.1.2.1 | grep `hexmac2decoid 00:10:DB:35:41:55`
SNMPv2-SMI::mib-2.17.7.1.2.2.1.2.1.0.16.219.53.65.85 = INTEGER: 1

This tells us that MAC address 00:10:DB:35:41:55 is reachable through port 1 on procurve1 (ref: Switching Tables).

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt