Finding IP address of Linux machine

1136685 pts.
Tags:
IP address
Linux
Is there a way I can find the IP address of my Linux machine? I'm using C++ and I have an application that's running on my Linux server so I need to find it. Thanks!
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    Check out this link, it explains it well.
    131,380 pointsBadges:
    report
  • ToddN2000
    Either that or try

    # /sbin/ifconfig

    131,380 pointsBadges:
    report
  • TheRealRaven
    It's much less common for an app to need to know its own address (especially since localhost, loopback or simply 127.0.0.1 should always mean "my system" anyway). Usually it's necessary to find addresses for other systems. Knowing its own address is commonly needed for some type of display for humans or perhaps for logging such as when generating some text for a syslog message.

    It's complicated because a large number of systems have multiple IP addresses, and you'll need to determine or specify (perhaps by host name) which address, or interface, you want.

    For a C++ app, the fundamental source would be the deprecated gethostbyname() function or the newer getaddrinfo() function, which should be preferred if you have the choice. The full descriptions should be read in order to get a picture of complications.

    The actual sequence of functions can depend on exactly what you are intending to use the address for.
    34,320 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: