6

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}]
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
BlackJoker
  • 3,099
  • 2
  • 20
  • 27

3 Answers3

7
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*
Colinux
  • 71
  • 1
  • 4
0

cat /proc/net/bonding/bondX

where bondX is the name of your bonded interface

Koby
  • 837
  • 7
  • 11
-1

NetworkInterface is useless, IMHO. I've never gotten reliable information from it. Execute ifconfig and parse the output, that is your best option.

UPDATE: awesome, somebody downvoted. So post an answer and show what works, because I stand by the assertion that NetworkInterface is unreliable. A modern alternative to ifconfig that is capable of showing bonding information is ip link show type bond.

brettw
  • 10,664
  • 2
  • 42
  • 59
  • ifconfig will hiding the unactive slave interfaces' MAC address,as mentioned in the UPDATE part of question body.And,ifconfig in fedora & sles has different output format. – BlackJoker Nov 21 '13 at 03:00