Meaningless Drivel is fun!*
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
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: 19543
    
  16

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: 19543
    
  16

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: 18118
    
  39

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting IP address of Interface whose network cable is unplugged
 
Similar Threads
How to run an application as name-based in tomcat
Assigning IP Address to network card in WinXP... HELP!
Way to get IP address through Java?
Setting up cablemodem...
Problem access to Tomcat in internet and intranet at the same time