I am just going through dhcp option sets and its mentioned that domain name and name-server are assigned through dhcp options. Now when i set the ip address statically during instance creation, then the ENI wont be running any dhcp. Now as i am typing this i realize that there is something behind the scenes because all other settings are not defined during instance creation so does it mean that our IP is assigned statically through dhcp (like some sort of host binding?).
1 Answers
You're hitting upon an interesting aspect of Amazon EC2 and its Elastic Network Interface (ENI) provisioning process.
When you launch an EC2 instance, even if you specify a static IP (in the case of EC2, this would be an Elastic IP or a specific private IP), the instance's operating system still goes through the DHCP process. Here's a breakdown of how it works:
Static Assignment via DHCP: The "static IP" is essentially provided to the instance through DHCP, a bit like a DHCP reservation in traditional networking. Amazon's Virtual Private Cloud (VPC) DHCP service provides the EC2 instance with the specific IP you've allocated (or a dynamic one if you didn't specify). This is why, in the operating system itself, the network interface is often still set to obtain an IP address automatically (via DHCP).
DHCP Options Set: The DHCP Options Set in a VPC lets you specify the domain names and name servers for instances that get their IP addresses via DHCP. This allows EC2 instances to know which Domain Name System (DNS) servers to use or what domain name to append for non-qualified domain names, among other settings.
When You Set a Static IP in the OS: If you were to manually configure the operating system of the EC2 instance to use a static IP (i.e., not use DHCP), then it would not get the settings from the DHCP Options Set. This is typically not recommended in EC2 unless you have a specific use case, because it can lead to IP conflicts and other unpredictable behavior. AWS expects and recommends using the VPC's DHCP to manage IP assignments, even if they are "static" IPs.
Why Use DHCP for Static IPs?: It allows AWS to manage the IP addressing scheme, ensuring that there are no conflicts and that each EC2 instance has the correct settings for the VPC, such as the local IP address for DNS resolution, correct routing, etc. It also enables features like EC2 instance metadata, which is available at a special IP address (
169.254.169.254
) and is provided via DHCP.
So, in summary, even if you're using a "static" IP in the context of AWS (like an Elastic IP), the underlying operating system is still typically using DHCP to get that IP and other settings.
[1] https://docs.aws.amazon.com/vpc/latest/userguide/vpc-ip-addressing.html

- 14,512
- 6
- 35
- 54
-
Thanks Piyush for the detailed answer. Again out of my own curiosity, is it discussed anywhere in aws documentation for further read? – adnan Aug 20 '23 at 09:42
-
So little bit of here https://docs.aws.amazon.com/vpc/latest/userguide/vpc-ip-addressing.html and some details are from my experience working on AWS Networking from long time – Piyush Patil Aug 20 '23 at 10:27