fix DNS resolving for IP addresses

patch by Stanislav Putrya

this and the previous commits should cover the PR #2