1

I have configured my Windows AWS instance to use two IP addresses and would like to be able to choose which of these two IPs are used for a HTTP GET request using curl (pycurl).

I want it to appear to the server-side that there are two separate clients - almost like one machine using itself as a proxy.

I have configured my instance to use 1.1.1.1 as the static IP and 2.2.2.2 as an additional (proxy) IP address.

> curl --interface 1.1.1.1 example.com

is successful, however, trying with the other IP address yields a Timeout.

> curl --interface 2.2.2.2 example.com
curl: (7) Failed to connect to example.com port 80: Timed out

Setting the verbose flag

> curl --interface 2.2.2.2 --verbose example.com
*   Trying 93.184.216.34:80...
* TCP_NODELAY set
* Name '2.2.2.2' family 2 resolved to '2.2.2.2' family 2
* Local port: 0
* connect to 93.184.216.34 port 80 failed: Timed out
* Failed to connect to example.com port 80: Timed out
* Closing connection 0
curl: (7) Failed to connect to example.com port 80: Timed out

Can anyone please shed any light on why this connection might be failing when using the second IP (and how one might fix this in Windows)?

Thank you in advance!

2
  • How are the routes on the client and server? – Gerald Schneider Sep 4 '19 at 14:38
  • @GeraldSchneider sorry I'm not too sure what you mean? I'm pretty new to this sort of thing – Huw Thomas Sep 4 '19 at 14:40
1

It sounds like it might be a routing issue, can you ping or traceroute to the address? Check route print or Get-NetRoute in PowerShell to get an idea of whether the correct gateway is in place - the third column in each will tell you where a request is going for a given address (you probably want to look for the NextHop corresponding to DestinationPrefix 0.0.0.0/0).

You need to look for issues in how the device routes your request to different IPs for the different interfaces to solve the issue.

3
  • I can ping 2.2.2.2 and traceroute gives 1 hop back to my own machine. – Huw Thomas Sep 4 '19 at 15:51
  • And what does the routing table look like? See the other commands suggested in the anwer – LTPCGO Sep 4 '19 at 15:54
  • Sorry, I hit enter before I had finished adding everything! In route print for the 0.0.0.0 destination, I see 0.0.0.0 as the Netmask and my correct gateway with 2.2.2.2 as the interface. Get-NetRoute gives again my gateway for the destination 0.0.0.0/0. I'm surprised that in the Interface column for tracert I only see entries for 2.2.2.2 and not any for 1.1.1.1. – Huw Thomas Sep 4 '19 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.