Find public IP with POCO
<p>How can I find my public IP using POCO?</p>

<p>Inspired by page 6 of <a href="https://pocoproject.org/slides/200-Network.pdf" rel="nofollow">their Network presentation</a>, I tried the following:</p>

<pre><code>#include "Poco/Net/DNS.h"
#include &lt;iostream&gt;
using Poco::Net::DNS;
using Poco::Net::HostEntry;
int main(int argc, char** argv)
{
    const HostEntry&amp; entry = DNS::thisHost();
    std::cout &lt;&lt; "Canonical Name: " &lt;&lt; entry.name() &lt;&lt; std::endl;

    const HostEntry::AliasList&amp; aliases = entry.aliases();
    HostEntry::AliasList::const_iterator alias_it = aliases.begin();
    for (; alias_it != aliases.end(); ++alias_it)
        std::cout &lt;&lt; "Alias: " &lt;&lt; *alias_it &lt;&lt; std::endl;

    const HostEntry::AddressList&amp; addrs = entry.addresses();
    HostEntry::AddressList::const_iterator addr_it = addrs.begin();
    for (; addr_it != addrs.end(); ++addr_it)
        std::cout &lt;&lt; "Address: " &lt;&lt; addr_it-&gt;toString() &lt;&lt; std::endl;

    return 0;
}
</code></pre>

<p>This, however, returned two addresses: one IPv6 link-local (fe80:...) and one private LAN IPv4 (10.0...). It did not return my public IP.</p>

<p>Can this be done?</p>