S
subscriber
I have a strange problem. When I try to determine my machine's IP
address from Java (ver 1.4.2_06), I get the wrong result. It reports
192.168.0.88 when the address is actually 192.168.0.60.
I am running SuSE 9.2.
Here's the code (which gives the output "algw-05/192.168.0.88"):
public class TestMain {
public static void main(String[] args) {
try {
String myHostName =
InetAddress.getLocalHost().getHostName();
InetAddress[] myAddresses =
InetAddress.getAllByName(myHostName);
for (int i = 0; i < myAddresses.length; i++) {
System.out.println(myAddresses.toString());
}
}
catch (UnknownHostException ignored) {
}
}
}
And here's the output from ifconfig:
ath0 Link encap:Ethernet HWaddr 00:05:4E:46:6F:7D
inet addr:192.168.0.60 Bcast:192.168.0.255
Mask:255.255.255.0
inet6 addr: fe80::205:4eff:fe46:6f7d/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:19954 errors:148 dropped:0 overruns:0 frame:148
TX packets:17833 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:199
RX bytes:18750042 (17.8 Mb) TX bytes:2639289 (2.5 Mb)
Interrupt:11 Memory:f9220000-f9230000
Any ideas?
// Ake
address from Java (ver 1.4.2_06), I get the wrong result. It reports
192.168.0.88 when the address is actually 192.168.0.60.
I am running SuSE 9.2.
Here's the code (which gives the output "algw-05/192.168.0.88"):
public class TestMain {
public static void main(String[] args) {
try {
String myHostName =
InetAddress.getLocalHost().getHostName();
InetAddress[] myAddresses =
InetAddress.getAllByName(myHostName);
for (int i = 0; i < myAddresses.length; i++) {
System.out.println(myAddresses.toString());
}
}
catch (UnknownHostException ignored) {
}
}
}
And here's the output from ifconfig:
ath0 Link encap:Ethernet HWaddr 00:05:4E:46:6F:7D
inet addr:192.168.0.60 Bcast:192.168.0.255
Mask:255.255.255.0
inet6 addr: fe80::205:4eff:fe46:6f7d/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:19954 errors:148 dropped:0 overruns:0 frame:148
TX packets:17833 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:199
RX bytes:18750042 (17.8 Mb) TX bytes:2639289 (2.5 Mb)
Interrupt:11 Memory:f9220000-f9230000
Any ideas?
// Ake