Search code examples
javamac-addressnetwork-interface

How do I find the original MAC addresses on linux interface-bounding process in Java?


interface-bounding:The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical bonded interface. The logical bounded interface will have only one MAC address,which is bounded from one of the original interfaces. ifconfig will show all the original interfaces with the same MAC address.

Now,I'm going to found the original MAC address of each interface in Java.How ?

I has confirmed that I can't find them through NetworkInterface.getInterfaceAddresses() and NetworkInterface.getSubInterfaces()

Any other ways?

UPDATE:

before bounding: enter image description here

after bound eth1 and eth2 to bound0: enter image description here

The java code show interfaces info:

ALL interfaces:[name:bond0 (bond0), name:eth0 (eth0), name:lo (lo)]
they are [{netIf bond0,host 192.168.122.38,mac 525400F801B9,ip 192.168.122.38}, {netIf eth0,host hatest02,mac 5254008C5B48,ip 192.168.10.38}]

Solution

  • cat /proc/net/bonding/bond0
    

    Will show you the original mac's for both bonded interfaces

    Full output, less private data below:

    Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
    Bonding Mode: fault-tolerance (active-backup)
    Primary Slave: None
    Currently Active Slave: eno49
    MII Status: up
    MII Polling Interval (ms): 100
    Up Delay (ms): 0
    Down Delay (ms): 0
    
    Slave Interface: eno49
    MII Status: up
    Speed: 1000 Mbps
    Duplex: full
    Link Failure Count: 0
    Permanent HW addr: 28:80:23:xx:xx:ec
    Slave queue ID: 0
    
    Slave Interface: eno50
    MII Status: down
    Speed: Unknown
    Duplex: Unknown
    Link Failure Count: 0
    Permanent HW addr: 28:80:23:xx:xx:ed
    Slave queue ID: 0*