File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes NetworkInterface.isUp() is returning false for the interface which is up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "NetworkInterface.isUp() is returning false for the interface which is up" Watch "NetworkInterface.isUp() is returning false for the interface which is up" New topic
Author

NetworkInterface.isUp() is returning false for the interface which is up

Ravikanth Boorugadda
Greenhorn

Joined: Apr 07, 2009
Posts: 3

I have a strange problem, windows ipconfig/all is showing the interface with ipaddress. But java is returning false for isUp() for the NetworkInterface.

I am running this code on Windows.

Here is the piece of code:
Enumeration<NetworkInterface> nwIfs = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface nwIf : Collections.list(nwIfs)) {
System.out.println("Interface = " + nwIf);
System.out.println("Interface is Up =" + nwIf.isUp());
System.out.println("Interface is virtual =" + nwIf.isVirtual());
System.out.println("Interface MTU =" + nwIf.getMTU());
System.out.println("Interface parent =" + nwIf.getParent());
System.out.println("Interface is loopback =" + nwIf.isLoopback());
System.out.println("Interface is point to point =" + nwIf.isPointToPoint());
System.out.println("Interface support Muticast =" + nwIf.supportsMulticast());

Here is the output:

Interface = name:eth4 (AAAAAAAA) index: 0 addresses:
/10.1.20.2;

Interface is Up =false
Interface is virtual =false
Interface MTU =1500
Interface parent =null
Interface is loopback =false
Interface is point to point =false
Interface support Muticast =true

Here is the ipconfig output for the interface
Ethernet adapter XXXXXXX:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : AAAAAAAA
Physical Address. . . . . . . . . : XX-XX-XX-XX-XX-XX
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.1.20.2(Preferred)
Subnet Mask . . . . . . . . . . . : 255.0.0.0
Default Gateway . . . . . . . . . :
NetBIOS over Tcpip. . . . . . . . : Enabled

Any clue why the NetworkInterface code is behaving this way.
I have already posted this in forums.oracle.com, but didn't get any response.
Ravikanth Boorugadda
Greenhorn

Joined: Apr 07, 2009
Posts: 3
One more observation is , index is 0 for all the interfaces.
Raghu Shank
Greenhorn

Joined: Jul 19, 2011
Posts: 3
I executed the same program. I got the results as expected. Please check the permission of user profile. Please also check the java version.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

Ravikanth Boorugadda wrote:One more observation is , index is 0 for all the interfaces.


Index?
Raghu Shank
Greenhorn

Joined: Jul 19, 2011
Posts: 3
I got the interface also. Please see the output below.

Interface is Up =true
Interface is virtual =false
Interface MTU =1520
Interface parent =null
Interface is loopback =true
Interface is point to point =false
Interface support Muticast =true
Interface = name:eth0 (VMware Virtual Ethernet Adapter for VMnet8) index: 2 addresses:
/192.168.63.1;

Interface is Up =true
Interface is virtual =false
Interface MTU =1500
Interface parent =null
Interface is loopback =false
Interface is point to point =false
Interface support Muticast =true
Interface = name:eth1 (VMware Virtual Ethernet Adapter for VMnet1) index: 3 addresses:
/192.168.221.1;

Interface is Up =true
Interface is virtual =false
Interface MTU =1500
Interface parent =null
Interface is loopback =false
Interface is point to point =false
Interface support Muticast =true
Interface = name:eth2 (Intel(R) 82566DM Gigabit Network Connection - Teefer2 Miniport) index: 4 addresses:
/10.10.98.183;

Interface is Up =true
Interface is virtual =false
Interface MTU =1500
Interface parent =null
Interface is loopback =false
Interface is point to point =false
Interface support Muticast =true
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NetworkInterface.isUp() is returning false for the interface which is up
 
Similar Threads
NetworkInterface.getByInetAddress() in a remote computer
getHardwareAddress returning null with JDK 6 Update 22 enabled browser
How to know programmatically whether a machne is in Global/Private network ?
SocketException
Background process to monitor network interfaces