SNMP get vlan information


Userlevel 3
Hi everybody!

I'd like to get some information about vlans on ports. Unfortunately, XOS doesn't respond to standard dot1qVLanStaticTable OID (.1.3.6.1.2.1.17.7.1.4.3). So, I've decided to use extremePortVlanInfoTable private OID. But I can't find tagged/untagged information.

Can anybody suggest something?
Thanks.

2 replies

Userlevel 5
Hello,
I have a homegrown little app for switchports and what VLAN they're in, and which ports are tagged/untagged.

"vname" => ".1.3.6.1.4.1.1916.1.2.1.2.1.2", //extremeVlanIfDescr.vlan_no = string NOT the tag
"vport" => ".1.3.6.1.4.1.1916.1.4.17.1.1", //extremePortVlanInfoDescr.port.vlan_no = string
"vtag" => ".1.3.6.1.4.1.1916.1.2.1.2.1.10", //extremeVlanIfVlanId.vlan_no = integer
"tagged" => ".1.3.6.1.4.1.1916.1.2.6.1.1.1", //extremeVlanOpaqueTaggedPorts .VLANid.SLOT = Hex-String
"untagged" => ".1.3.6.1.4.1.1916.1.2.6.1.1.2" //extremeVlanOpaqueUntaggedPorts .VLANid.SLOT = Hex-String[/code]

Caveat programmer: That hex string is as mean as those hex strings can get. Basically it's a hex representation of a 256 bit binary string, where the Nth position of the binary "1" or "0" means that port N is tagged (untagged) or not respectively.
For instance: "01 00 00.....00" would mean:
00000001 00000000 00000000 ...., which in turn means "port 8 is (un)tagged" (depending on which OID you query)

Code snippet in PHP (for string-to-hex-to-bin conversion): $value being the value of the OID query, in this case "untagged"

$hex=trim(substr(strstr($value,":"),1)); // converting string to hex
$hex = preg_replace("/[ \n]/","",$hex); // step two, get rid of spaces and newlines
$bin = gmp_convert($hex, 16, 2); // convert hex to binary
$bin = str_pad($bin,256,"0", STR_PAD_LEFT); // left-pad the binary string with zeros,
// so that we don't converting "01 00 hex" to "1 00000000" binary[/code]
And that might be the reason why things never tell you "this port is in VLAN X, tagged/untagged", but only "here are the tagged/untagged ports of a vlan".

Hope that helps - oh, and if anyone has a better way of skinning this particular cat, please share! 🙂
Userlevel 3
Frank wrote:

Hello,
I have a homegrown little app for switchports and what VLAN they're in, and which ports are tagged/untagged.

"vname" => ".1.3.6.1.4.1.1916.1.2.1.2.1.2", //extremeVlanIfDescr.vlan_no = string NOT the tag
"vport" => ".1.3.6.1.4.1.1916.1.4.17.1.1", //extremePortVlanInfoDescr.port.vlan_no = string
"vtag" => ".1.3.6.1.4.1.1916.1.2.1.2.1.10", //extremeVlanIfVlanId.vlan_no = integer
"tagged" => ".1.3.6.1.4.1.1916.1.2.6.1.1.1", //extremeVlanOpaqueTaggedPorts .VLANid.SLOT = Hex-String
"untagged" => ".1.3.6.1.4.1.1916.1.2.6.1.1.2" //extremeVlanOpaqueUntaggedPorts .VLANid.SLOT = Hex-String[/code]

Caveat programmer: That hex string is as mean as those hex strings can get. Basically it's a hex representation of a 256 bit binary string, where the Nth position of the binary "1" or "0" means that port N is tagged (untagged) or not respectively.
For instance: "01 00 00.....00" would mean:
00000001 00000000 00000000 ...., which in turn means "port 8 is (un)tagged" (depending on which OID you query)

Code snippet in PHP (for string-to-hex-to-bin conversion): $value being the value of the OID query, in this case "untagged"

$hex=trim(substr(strstr($value,":"),1)); // converting string to hex
$hex = preg_replace("/[ \n]/","",$hex); // step two, get rid of spaces and newlines
$bin = gmp_convert($hex, 16, 2); // convert hex to binary
$bin = str_pad($bin,256,"0", STR_PAD_LEFT); // left-pad the binary string with zeros,
// so that we don't converting "01 00 hex" to "1 00000000" binary[/code]
And that might be the reason why things never tell you "this port is in VLAN X, tagged/untagged", but only "here are the tagged/untagged ports of a vlan".

Hope that helps - oh, and if anyone has a better way of skinning this particular cat, please share! 🙂

That's great! Thanks!

Reply