Obtain the MAC address based on IP addres

Version 1
    This document was generated from CDN thread

    Created by: Tom Barrand on 26-08-2009 04:21:36 PM
    Hi,
     
    How can I obtain the MAC address from CUCM based on the IP address?
     
    Thanks
     
    Tom

    Subject: RE: Obtain the MAC address based on IP addres
    Replied by: Kevin Schantz on 26-08-2009 07:02:26 PM
    It might be easier to find a way to do this outside of cisco's tools(send a query to your dhcp server or something), however my first guess would be to use risport.

    Subject: RE: Obtain the MAC address based on IP addres
    Replied by: David Staudt on 26-08-2009 08:20:52 PM
    You can query the AXL Risport web service: http://www.cisco.com/en/US/docs/voice_ip_comm/cucm/devguide/7_1_2/serviceability.html#wp1053885
     
    With SelectCmDevice you can provide an IP address and it will return the device name.  By convention, hardware phone device names are in the form 'SEPxxxxxxxxxxxx' where 'xxxxxxxxxxxx' is the MAC address.  Note this may not be true for softphones and other types of devices.
     
    Note, you can also query the phone's onboard web server, to retrieve basic information: http://[phone_IP]/DeviceInformationX

    Subject: RE: Obtain the MAC address based on IP addres
    Replied by: Tom Barrand on 28-08-2009 08:15:30 AM
    Hi David,
     
    Please can you provide a bit more info regarding how we specify the IP address of the device that we would like the MAC address for.
     
    I have detailed some of the code that we are using to do this below.
     
    FYI - we have used Axis 1.4 and WSDL2Java to create the stubs.
     
    Many thanks
     
    Tom
     

     
     
     








     


    <font size="2">
    CmSelectionCriteria query=
    </font>
     
    new
    CmSelectionCriteria();<font size="2">
    query.setStatus(
    </font>
     
    "Any"
    );<font size="2">
    query.set_class(
    </font>
     
    "Phone"
    );<font size="2">
    query.setSelectBy(
    </font>
     
    "Name"
    );<font size="2">
    query.setMaxReturnedDevices(
    </font>
     
    new
    UnsignedInt(255));
     
    SelectCmDeviceResult res = type.selectCmDevice(si,query);
     
    <font size="2">
     
    </font>
     
    if (res!=null
    ){
    CmNode[] nodes = res.getCmNodes();
    <font size="2">
     
    </font>
     
    if (nodes!=null
    )<font size="2">
     
    </font>
     
    for(int i=0;i<nodes.length
    ;i++){<font size="2">
    System.
    </font>
     
    out.println("CCM "
    +nodes.getName());
    CmDevice[] devices = nodes.getCmDevices();
    <font size="2">
     
    </font>
     
    if (devices!=null
    )<font size="2">
     
    </font>
     
    for(int j=0;j<devices.length
    ;j++){<font size="2">
    System.
    </font>
     
    out.println(j+" IP Address "+devices.getIpAddress()+" Name " + devices.getName()+ " Dir Number "+devices.getDirNumber()+" Product "
    +devices.getProduct()<font size="2">
    +
    </font>
     
    " Status "
    +devices.getStatus());
     
    <font size="2">
     
    </font>
     
    if (devices.getIpAddress().indexOf(".13"
    )!=-1)<font size="2">
    push(
    </font>
     
    new String[]{}, devices.getIpAddress(), "locator", "an3C13c0", true
    );

    Subject: RE: Obtain the MAC address based on IP addres
    Replied by: David Staudt on 28-08-2009 02:16:31 PM
    I think basically the difference is instead of <SelectBy> using 'Name' substitute 'IpAddress'  (case sensitive), and provide the IP in the SelectItems array.  There is a sample on the SXML wiki here that shows using SelectCmDevice with the SelectItems array:http://developer.cisco.com/web/sxml/wikidocs?src=/wiki/display/SXML/IP+Address+Report
     
    The line here:
     
    <pre class="code-java">SelectItem[] items = {new SelectItem("*")};

    would change to

    SelectItem[] items = {new SelectItem("10.89.121.9")};

    substituting of course the actual IP you want to query.

    </pre>

    Subject: RE: Obtain the MAC address based on IP addres
    Replied by: Tom Barrand on 01-09-2009 04:18:19 PM
    Thanks for pointing me to the example.
     
    I've managed to set the IP address in the query which works but it seems unclear on how to retrieve the MAC address in the results? I've attached a screenshot.
     
    I've also looked at the WSDL and dont see MAC, unless it is called something that isn't obvious?
     
    Thanks
     
    Tom
     

      <element name="Name" type="xsd:string" />


      <element name="IpAddress" nillable="true" type="xsd:string" />


      <element name="DirNumber" nillable="true" type="xsd:string" />


      <element name="Class" nillable="true" type="tnseviceClass" />


      <element name="Model" nillable="true" type="xsd:unsignedInt" />


      <element name="Product" nillable="true" type="xsd:unsignedInt" />


      <element name="BoxProduct" nillable="true" type="xsd:unsignedInt" />


      <element name="Httpd" nillable="true" type="tns:CmDevHttpd" />


      <element name="RegistrationAttempts" type="xsd:unsignedInt" />


      <element name="IsCtiControllable" type="xsd:boolean" />


      <element name="LoginUserId" nillable="true" type="xsd:string" />


      <element name="Status" type="tns:CmDevRegStat" />


      <element name="StatusReason" nillable="true" type="xsd:unsignedInt" />


      <element name="PerfMonObject" nillable="true" type="xsd:unsignedInt" />


      <element name="DChannel" nillable="true" type="xsd:unsignedInt" />


      <element name="Description" nillable="true" type="xsd:string" />


      <element name="H323Trunk" nillable="true" type="tns:H323Trunk" />


      <element name="TimeStamp" nillable="true" type="xsd:unsignedInt" />

    Subject: RE: Obtain the MAC address based on IP addres
    Replied by: David Staudt on 01-09-2009 06:22:23 PM
    The <name> element is what you will want to look at.  For hardware phones _by convention_ the MAC is part of the device's name, in format such as: SEP234484958726, where everthing after 'SEP' is the MAC.  Note, a given device _can_ have an arbitrary device name, an example would be an IP Communicator with device name 'DavidS_IPC'.
     
    The real/actual MAC address of course is not known to UCM, due to the nature of TCP/IP internetworking.
     
    You can query the phone directly (if you have the IP address,) by requesting (via HTTP GET on port 80) the URL: http://[phone_ip]/DeviceInformationX, which will return an XML object which includes (real) MAC:
     
    - <DeviceInformation>
      <MACAddress>93838738374384</MACAddress>
      <HostName>DavidS_IPC</HostName>
      <phoneDN>1000</phoneDN>
      <appLoadID>7.0.3.0</appLoadID>
      <bootLoadID>7.0.3.0</bootLoadID>
      <versionID>7.0.3.0</versionID>
      <addonModule1 />
      <addonModule2 />
      <hardwareRevision>0.0</hardwareRevision>
      <serialNumber />
      <modelNumber>Cisco Communicator</modelNumber>
      <MessageWaiting>No</MessageWaiting>
      <udi>phone Cisco Communicator</udi>
      <time>18:19:52</time>
      <timezone>Greenwich Standard Time</timezone>
      <date>09/01/09</date>
      </DeviceInformation>

    Subject: RE: Obtain the MAC address based on IP addres
    Replied by: Tom Barrand on 02-09-2009 09:01:12 AM
    Thanks for clarifying. All makes sense now.