diff --git a/src/lsd.cpp b/src/lsd.cpp index 7a5803afd..5fa0402dd 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -84,6 +84,9 @@ void lsd::rebind(address const& listen_interface) udp::resolver::iterator i = r.resolve(udp::resolver::query(asio::ip::host_name(), "0")); for (;i != udp::resolver_iterator(); ++i) { + // ignore the loopback + if (i->endpoint().address() == address_v4((127 << 24) + 1)) continue; + // ignore non-IPv4 addresses if (i->endpoint().address().is_v4()) break; } diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 9db14093c..22102b016 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -74,6 +74,9 @@ void natpmp::rebind(address const& listen_interface) try udp::resolver::iterator i = r.resolve(udp::resolver::query(asio::ip::host_name(), "0")); for (;i != udp::resolver_iterator(); ++i) { + // ignore the loopback + if (i->endpoint().address() == address_v4((127 << 24) + 1)) continue; + // ignore non-IPv4 addresses if (i->endpoint().address().is_v4()) break; } diff --git a/src/upnp.cpp b/src/upnp.cpp index 2a0be360b..8b13ccbd2 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -95,13 +95,16 @@ void upnp::rebind(address const& listen_interface) try udp::resolver::iterator i = r.resolve(udp::resolver::query(asio::ip::host_name(), "0")); for (;i != udp::resolver_iterator(); ++i) { + // ignore the loopback + if (i->endpoint().address() == address_v4((127 << 24) + 1)) continue; + // ignore non-IPv4 addresses if (i->endpoint().address().is_v4()) break; } if (i == udp::resolver_iterator()) { throw std::runtime_error("local host name did not resolve to an " - "IPv4 address. disabling NAT-PMP"); + "IPv4 address. disabling UPnP"); } m_local_ip = i->endpoint().address().to_v4();