My OS is CentOS 6. In my /etc/sysconfig/network-scripts/ifcfg-eth0 file, I have specified the network interface "NAME" to "foo" (let's suppose).
NAME=foo
I want to be able to get that interface "NAME" from java. I tried the following, without a result:
for (Enumeration nis = NetworkInterface.getNetworkInterfaces(); nis.hasMoreElements();) {
NetworkInterface ni = nis.nextElement();
System.out.println(ni.getDisplayName() + " " + ni.getName());
}
It displays the same thing:
eth0 eth0
Can anybody tell me if it is possible to get the value of NAME, property of a network interface, in java?
Thanks.
NOTE: When specify NAME=foo, then the name of that interface in the network panel placed on the up right corner of the screen is foo.
Are you sure you have changed the NIC name properly, please check the following link CentOS NIC name change