3

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!

Huw Thomas
  • 141
  • 1
  • 4

1 Answers1

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.

LTPCGO
  • 508
  • 1
  • 3
  • 15
  • I can ping 2.2.2.2 and traceroute gives 1 hop back to my own machine. – Huw Thomas Sep 04 '19 at 15:51
  • And what does the routing table look like? See the other commands suggested in the anwer – LTPCGO Sep 04 '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 04 '19 at 16:01