This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes getting IP address of Interface whose network cable is unplugged Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "getting IP address of Interface whose network cable is unplugged" Watch "getting IP address of Interface whose network cable is unplugged" New topic
Author

getting IP address of Interface whose network cable is unplugged

Suparn Gupta
Greenhorn

Joined: Feb 26, 2012
Posts: 16
Hi!
I have a system with three NIC each on different subnet. I am working on a code that wants me to get the ip address of all the interfaces even if no network cable is connected to them. I dont need the IP addresses of the disabled interfaces. Please help me. It kinda urgent!!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

Suparn Gupta wrote:It kinda urgent!!

Please EaseUp. There is no such thing as urgent around here.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

Did you already check out what you can do with java.net.NetworkInterface?
Suparn Gupta
Greenhorn

Joined: Feb 26, 2012
Posts: 16
Yeah I have checked the java.net package. When I enumerate the network interfaces using getNetworkInferfaces() it doesnt show the nic whose cable is unplugged. Even if I use netsh tool and extract the ip addresses from the output of the command, it wont do my job. I must get a NetworkInterface object for every interface as I have to use it in further code.

Take your time :-)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18765
    
  40

Suparn Gupta wrote:Yeah I have checked the java.net package. When I enumerate the network interfaces using getNetworkInferfaces() it doesnt show the nic whose cable is unplugged. Even if I use netsh tool and extract the ip addresses from the output of the command, it wont do my job. I must get a NetworkInterface object for every interface as I have to use it in further code.

Take your time :-)



I believe the java.net package only reports the NICs which are visible via the OS ... meaning if you run "ipconfig" (windows) or "ifconfig" (unix), it should show up. If it doesn't, there is nothing that can be done at the Java layer, it's a operating system or networking issue (you need to talk to your system or network administrator).

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Suparn Gupta
Greenhorn

Joined: Feb 26, 2012
Posts: 16
Hi Henry!

I too suspect that. I ll contact my lab admin and see what he has to say.
 
Don't get me started about those stupid light bulbs.
 
subject: getting IP address of Interface whose network cable is unplugged