Geetting the output from lo than eth0
Following code I used to get the ip address of my computer running GNU/
Linux:
import java.net.*;
class getadd {
public static void main(String args[]) throws
UnknownHostException {
InetAddress abc[] =
InetAddress.getAllByName("Ezeebee");
System.out.println("pls wait...");
for(int i = 0;i<abc.length;i++) {
System.out.print(abc[i]);
System.out.println("
"+abc[i].isMulticastAddress());
}
}
}
The problem is I get ip address of lo device rather than eth0. Here is
the output from 'ifconfig' comand:
eth0 Link encap:Ethernet HWaddr 00:0D:61:10:84:55
inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:
255.255.255.0
inet6 addr: fe80::20d:61ff:fe10:8455/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30045 errors:0 dropped:0 overruns:0 frame:0
TX packets:31435 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32270102 (30.7 MiB) TX bytes:4117926 (3.9 MiB)
Interrupt:20 Base address:0x4000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4771 errors:0 dropped:0 overruns:0 frame:0
TX packets:4771 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1932472 (1.8 MiB) TX bytes:1932472 (1.8 MiB)