Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Why the 127.0.1.1?

Thread view: 
Amankwah - 02 Jul 2007 14:52 GMT
I used the InetAddress.getLocalHost() to get my IP address, buy i got
127.0.1.1?
How can i get my REAL ip address?
Gordon Beaton - 02 Jul 2007 15:13 GMT
> I used the InetAddress.getLocalHost() to get my IP address, buy i
> got 127.0.1.1? How can i get my REAL ip address?

That is one of your REAL ip adresses.

To get all of them (and choose one you like better) have a look at
java.net.NetworkInterface.getNetworkInterfaces().

/gordon

--
Tom Hawtin - 02 Jul 2007 15:22 GMT
> I used the InetAddress.getLocalHost() to get my IP address, buy i got
> 127.0.1.1?
> How can i get my REAL ip address?

Are you using a Debian-based distribution of Linux? IIRC, when recent
Debian releases are using DHCP, in order to give a consistently
functioning IP address it uses this address. I think this is necessary
for Gnome. Addresses in the 127 class-A network should never appear on
the (physical) wire.

The obvious solution is not to use dynamic IP assignment, but that is
perhaps not very helpful.

I tried getAllByName using my hostname, but only got the one result
(using Ubuntu 7.04).

From 1.6, it appears with a little experimentation that you can get
java.net.NetworkInterface to get the information.

        for (
            java.util.Enumeration<NetworkInterface> en =
                NetworkInterface.getNetworkInterfaces();
            en.hasMoreElements();
        ) {
            NetworkInterface iface = en.nextElement();
            System.err.println(iface.getInterfaceAddresses());
        }

I have absolutely no idea why an interface introduced in 1.6 is still
using Enumeration.

Tom Hawtin
Amankwah - 03 Jul 2007 02:24 GMT
> > I used the InetAddress.getLocalHost() to get my IP address, buy i got
> > 127.0.1.1?
[quoted text clipped - 28 lines]
>
> Tom Hawtin

Thanks!
it's worked!

Amankwah
Roedy Green - 02 Jul 2007 17:04 GMT
>I used the InetAddress.getLocalHost() to get my IP address, buy i got
>127.0.1.1?
>How can i get my REAL ip address?

What you want is  your "FACE IP".

See http://mindprod.com/jgloss/ip.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.