With modern versions of curl, you can simply override which ip-address to connect to, using --resolve or --connect-to (curl newer than version 7.49). This works even with SSL/SNI. All details are in the man page.
For example, to override DNS and connect to www.example.com with ssl using a particular ip address: (This will also override ipv6)
curl --resolve www.example.com:443:192.168.42.2 https://www.example.com/
Another example, to connect to a particular backend server named backend1 on port 8080
curl --connect-to www.example.com:80:backend1.example.com:8080 http://www.example.com/
Remember to add the host header if the server needs that to answer correctly:
-H 'Host:www.example.com'