0

I'm testing one thing for my school project, where I need to connect to a single server, which is a website running on a home server, from multiple IPs for which I'd like to use AWS.

I have an AWS Free Tier microinstance, and I can buy multiple IPs for the machine. I will use either PHP/Python/Ruby to connect to a website and parse data from a counter on the site.

I'd like to run five scripts simultaneusly (using screen in Linux) on the instance, each with a separate IP connecting to the website every few seconds.

How can I force a script in PHP, Ruby or Python to use a certain connection, with a certain IP for outgoing connections from within the code without any system settings?

I know that it could be done using five instances, but it's more expensive and I'd really like to do it with a single instance. Is there any way to acheive this?

Thank you in advance!

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
kellins
  • 90
  • 9
  • Thank you! I couldn't find it (didn't know there is something called curl). The problem is therefore solved. Shall I delete the question? – kellins Nov 26 '13 at 02:14
  • i don't think a deletion is needed. the stackoverflow team should handle this – peaceman Nov 26 '13 at 06:30
  • 1
    kellins - one other problem is that you should run the instance in a vpc in order to be able to assign multiple elastic IPs. – andreimarinescu Nov 26 '13 at 08:49
  • @andreimarinescu Thank you, according to your comment and the answer below I guess that it will be way more complicated than I hoped :D – kellins Nov 27 '13 at 20:11
  • Adding a VPC isn't very complicated, it means clicking a few buttons in the management console :) As for the IP address, the way I would do it is: host a domain in Route53 and create an A record for each elastic IP. You can then write a script that calls each A record. You should be able to do it in a few hours with basic knowledge of hwo things work :) – andreimarinescu Nov 28 '13 at 08:40

1 Answers1

1

Based on the documentation, it doesn't look like you could do 5 different addresses with a single micro instance.

You can bind multiple network interfaces to an instance and multiple IP addresses to each interface, but there are limitations.

A t1.micro instance running in EC2-VPC is limited to 2 elastic network interfaces (ENI), each ENI is limited to 2 private IP addresses, and each private IP address is limited to 1 public elastic IP... so the maximum number of addresses possible with a t1.micro appears to be 4:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI

Or, if your instance is running in EC2-Classic and not EC2-VPC, you can't bind multiple IP addresses to a single EC2 instance so are limited to one public IP per instance.

However... the EC2 free tier is an allotment of enough hours to run a single instance -- but not technically an allotment of a single instance... so if you were to, for example, leave your single instance stopped for 12 hours one night, you could run the 5 machines for up to 2 hours each during the same month for free.

You can run one micro instance continuously for a month, or ten micro instances for 75 hours a month. How you spend your free tier allotment is up to you.

http://docs.aws.amazon.com/gettingstarted/latest/awsgsg-intro/gsg-aws-free-tier-usage-limits.html

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
  • Thank you for the clarification! I didn't know about this limit and it changes the situation a bit :/ – kellins Nov 27 '13 at 20:05