Haxx ad

curl's project page on


cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

Re: Using libcurl to get local Network IP for ETH0 and ETH1

From: Yves Arrouye <>
Date: Fri, 21 Dec 2012 10:21:09 -0800

> I'd say ioctl() and SIOCGIFADDR seem like a much easier way to get that

Or check out getifaddrs(3). Attached are a couple files I've used in a
home project that will get you in the right direction (look at
get_if_info, you can also call get_first_if_up_with_mac_addr() to get the
first interface that is up and has a physical (MAC) address, then call
get_if_info() on that).

Feel free to reuse, borrow etc. from that. No warranties :)


On 12/21/12 4:54 AM, "Daniel Stenberg" <> wrote:

>On Thu, 20 Dec 2012, Bernard Evensrud wrote:
>> Can libcurl from within a C application be used to get the network IP
>> address for ETH0 and ETH1 on Linux, just like ifconfig eth0 | grep
>> \"inet addr\" | awk -F: '{print $2}' | awk '{print$1}'?
>You can tell libcurl to use that address as a source address when doing
>network operations by setting CURLOPT_INTERFACE.
>You can then extract that info with curl_easy_getinfo()'s
>> I do not need the localhost IP or external IP. Just the local network
>> received from DHCP.
>I'd say ioctl() and SIOCGIFADDR seem like a much easier way to get that
> /
>List admin:

List admin:

Received on 2012-12-21

These mail archives are generated by hypermail.

donate! Page updated January 05, 2012.
web site info

File upload with ASP.NET