0

I am using DHCP to assign primary IP addresses in a subnet within a Windows Amazon Web Services EC2 instance

To avoid issues where the boxes are rebooted and the DHCP address changes, I have assigned a secondary IP to the network adapter within the same VPC subnet which is static and I reference those in my app configuration files.

Although this has worked for months, this seems a little "hardcoded". I'm fairly new to AWS, and I'm sure there's a thousand and one ways to skin a cat, but is this considered 'best practice'?

1
  • 1
    Why don't you use automatic DHCP IP distribution instead of dynamic DHCP address distribution? Even after a reboot the boxes are getting the same address if you manage to set a specific IP for a specific MAC on the DHCP Server. Nov 25, 2014 at 10:52

1 Answer 1

0

By default, when you create an EC2 instance, you can choose to assign an available private IP address to any EC2 instance when it is first launched. This desired IP address will be on the primary network interface and it will maintain this IP address until it is terminated.

If you don't specify a private IP address on launch, then it will receive one via DHCP.

Once an EC2 instance is launched, it is not possible to change the private IP address of it's primary network interface. So if you need it to respond to a particular IP address, then you must add a second network interface, as you have done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .