Forum Discussion
Anthony_Gerace_
Nov 16, 2004Historic F5 Account
Retrieve vlan mac address with get_true_mac_address method
Hi!
I was tasked with the project to retrieve the MAC addresses in use by BIG-IP. I have attempted to use the get_true_mac_address method in ITCMNetworking/VLAN. I am getting nothing coming bac...
Nov 16, 2004
By default, VLANs don't have a Layer 2 static forwarding table defined. If your query on the VLAN for the true mac address and it hasn't been defined then the iControl request will return an empty string. Take a look at the Administration GUI and drill down into the VLAN in question and my guess that the forwarding table is empty.
I'll have to check into the code but I would think that get_true_mac_address() would go and query the physical mac address that the VLAN is sitting on but for some reason it is returning an empty string. I'm not sure if this is tied to the l2 forwarding table or not.
Another way to approach this is to get the interface the VLAN is configured on and use the ITCMNetworking::Interfaces interface to query the mac address of the physical adapter.
Here's some code that will query all VLANs, and for each one, query the interfaces associated with it and, from there, use the ITCMNetworking::Interfaces interface to query the mac of that interface.
&getVLANMacAddresses();
-----------------------------------------------------
checkResponse
-----------------------------------------------------
sub checkResponse()
{
my ($soapResponse) = (@_);
if ( $soapResponse->fault )
{
print $soapResponse->faultcode, " ",
$soapResponse->faultstring, "\n";
exit();
}
}
-----------------------------------------------------
Query Interface List
-----------------------------------------------------
sub getVLANMacAddresses()
{
$soapResponse = $VLAN->get_list();
&checkResponse($soapResponse);
@vlanList = @{$soapResponse->result};
foreach $vlan (@vlanList)
{
print "VLAN : $vlan\n";
$soapResponse = $VLAN->get_interfaces
(
SOAP::Data->name(vlan_name => $vlan)
);
&checkResponse($soapResponse);
@InterfaceEntryList = @{$soapResponse->result};
foreach $InterfaceEntry (@InterfaceEntryList)
{
$intf_name = $InterfaceEntry->{"intf_name"};
$intf_type = $InterfaceEntry->{"intf_type"};
$iType = "UNTAGGED";
if ( $intf_type == 0 )
{
$iType = " TAGGED";
}
$soapResponse = $Interfaces->get_mac_address
(
SOAP::Data->name(intf_name => $intf_name)
);
&checkResponse($soapResponse);
$macAddress = $soapResponse->result;
print " Interface $intf_name ($iType) : $macAddress\n";
}
}
}
-Joe
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects