Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I move EC2 instances to a different subnet?

I have a VPC set up in AWS. we have created 2 subnets (A/24 and B/24), straight using all the IP having no IP's/Subnets for further usage.

We find that the b/24 is not totally utilized and we are wasting the Ip address in that.

Now we want to reduce the subnet size and move the instances from B/24 to A/24. and create 4 smaller subnets from B/24 and of /28 range and move back the servers to one of the smaller subnets created.

Please advise what are the suggested best practices we can apply in a way that we should be able to keep our available servers in B/24 and create multiple subnets as well.

like image 293
Pasha Avatar asked Nov 27 '13 07:11

Pasha


People also ask

Can instances in different subnets talk to each other?

Devices in different subnets can communicate. That is the purpose of a router. Routers route packets between different networks. Even if devices in different networks are on the same layer-2 broadcast domain, you need a router to let the devices communicate at layer-3.

How many EC2 instances can I run in a subnet?

You can run any number of Amazon EC2 instances within a VPC, so long as your VPC is appropriately sized to have an IP address assigned to each instance. You are initially limited to launching 20 Amazon EC2 instances per VPC at any one time and a maximum VPC size of /16 (65,536 IPs).


1 Answers

Creating smaller subnets is pretty straight forward. Delete the subnet and create new subnets. However, you'll want to transition off the boxes in B/24 before you delete it.

Now, moving a running machine between subnets is not possible*. Depending on your application and your requirements, I imagine that shutting it down, taking an image of the machine, then launching a new instance of that machine in the other subnet will work.

*As an aside, I wondered if you could attach a new network interface from a new subnet and then remove your old network interface, effectively moving subnets without having the take the box down. As it turns out, you cannot remove the network interface at index 0, which means this does not work.

like image 52
Liyan Chang Avatar answered Sep 29 '22 08:09

Liyan Chang