Mobile Client MAC Address

In a real Vision client, you can obtain the local MAC addresses with the following script:

from java.net import NetworkInterface

# Get list of local mac address as strings
def myMacIds():
    macs = [ni.hardwareAddress for ni in NetworkInterface.getNetworkInterfaces() if ni.hardwareAddress]
    return [":".join(["%02x" % (b & 0xff) for b in mac]) for mac in macs]

Also, again in a real Vision client, you can obtain the outbound network interface and the corresponding local IP address the client uses to talk to the gateway with this script:

from java.net import DatagramSocket, InetAddress, NetworkInterface, URI

# Get the outbound network interface and local IP address (as a tuple).
def localInterface():
    gw = URI(system.tag.read('[System]Client/Network/GatewayAddress').value).host
    for ip in InetAddress.getAllByName(gw):
        socket = DatagramSocket()
        try:
            socket.connect(ip, 0)
            return NetworkInterface.getByInetAddress(socket.localAddress), socket.localAddress
        except:
            pass
        finally:
            socket.close()
    return None, None
4 Likes