Problem while getting ALL IP addresses after connected to VPN
843807Feb 5 2003 — edited Feb 6 2003Hi,
I am trying to get hold of IP Address that my desktop gets after connected to VPN.
So I wrote, small test program ipcheck and trying find out
whether InetAddress.getAllByName() works to list me all ip addresses including one my desktop got due to VPN connection.
But Unfortunately , program does not list IP address assigned by VPN connection.
is this a bug in InetAddress.getAllByName()?
Does anybody know how to get this (vpn assigned) ip address using JDK APIs?
Pls find below is my ipcheck program and its output together with "ipconfig" output before and after VPN connection for ur reference.
looking ahaead for ur replies
Thanks,
-Manoj
manojc@velankani.com
732 563 1427 x 124
================================================================
import java.lang.*;
import java.net.*;
class ipcheck
{
public static void main(String[] args)
{
System.out.println("IP Address Testing");
try {
String localIPAddress = InetAddress.getLocalHost().getHostAddress();
System.out.println("Local IP Address => " + localIPAddress);
InetAddress[] adrs = InetAddress.getAllByName(localIPAddress);
if (adrs != null) {
for(int i=0; i<adrs.length; i++)
{
System.out.println("IP Address [" + i + "] = " + adrs.getHostAddress());
}
}
else {
System.out.println("No Other IPs");
}
} catch (Exception e) {
System.out.println("Error: " + e);
e.printStackTrace();
}
System.out.println("Done");
}
================================================================
Before VPN connection
================================================================
$ ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.0.95
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.240
Ethernet adapter {8A4B9DD2-434A-4D95-8F30-C1A7D3712491}:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 0.0.0.0
Subnet Mask . . . . . . . . . . . : 0.0.0.0
Default Gateway . . . . . . . . . :
$ java ipcheck
IP Address Testing
Local IP Address => 192.168.0.95
IP Address [0] = 192.168.0.95
Done
================================================================
Behaviour After VPN connection
================================================================
$ ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.0.95
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.240
Ethernet adapter {8A4B9DD2-434A-4D95-8F30-C1A7D3712491}:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 0.0.0.0
Subnet Mask . . . . . . . . . . . : 0.0.0.0
Default Gateway . . . . . . . . . :
PPP adapter Velankani:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.63.226
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 192.168.63.226
Administrator@SE001 ~/tp
$ java ipcheck
IP Address Testing
Local IP Address => 192.168.0.95
IP Address [0] = 192.168.0.95
Done
================================================================