The goal is to direct curl's request to a specific interface, for example, tun0.
Assume tun0 has the IPv4 address of 192.168.15.2. Below is the command line:
mycurl --dns-ipv4-addr 192.168.15.2 --dns-interface tun0 --interface tun0 -4 www.yahoo.com
The default "curl" program in Debian/Ubuntu is not (as is Ubuntu 14.04) compiled with the lib-ares library, which is required for the above arguments to work. You will need to download the lib-ares library first (hosted by curl project), compile it, and then compile your own curl binary. To configure curl to use your newly installed lib-ares lib, do this:
"-4" argument is to tell curl to only use IPv4 IP. Otherwise it will wait for the IPv6 DNS resolving result, which for many sites may not be available and therefore causing curl to hang.