Network interface attachments for your EC2 instance
You can create network interfaces to be used by your EC2 instances as primary or secondary network interfaces. You must attach a network interface to an EC2 instance that is in the same Availability Zone. The instance type of an instance determines how many network interfaces you can attach to the instance. For more information, see Maximum IP addresses per network interface.
Considerations
-
You can attach a network interface to an instance when it's running (hot attach), when it's stopped (warm attach), or when the instance is being launched (cold attach).
-
You can detach secondary network interfaces when the instance is running or stopped. However, you can't detach the primary network interface.
-
You can move a secondary network interface from one instance to another, if the instances are in the same Availability Zone and VPC but in different subnets.
-
When launching an instance using the CLI, API, or an SDK, you can specify the primary network interface and additional network interfaces.
-
Launching an Amazon Linux or Windows Server instance with multiple network interfaces automatically configures interfaces, private IPv4 addresses, and route tables on the operating system of the instance.
-
A warm or hot attach of an additional network interface might require you to manually bring up the second interface, configure the private IPv4 address, and modify the route table accordingly. Instances running Amazon Linux or Windows Server automatically recognize the warm or hot attach and configure themselves.
-
You can't attach another network interface to an instance (for example, a NIC teaming configuration) to increase or double the network bandwidth to or from the dual-homed instance.
-
If you attach two or more network interfaces from the same subnet to an instance, you might encounter networking issues such as asymmetric routing. If possible, use a secondary private IPv4 address on the primary network interface instead.
-
For EC2 instances in an IPv6-only subnet, if you attach a secondary network interface, the private DNS hostname of the secondary network interface resolves to the primary IPv6 address for the primary network interface.
-
Windows instances – If you use multiple network interfaces, you must configure the network interfaces to use static routing.
Attach a network interface
You can attach a network interface to any instance in the same Availability Zone as the network interface, using either the Instances or Network Interfaces page of the Amazon EC2 console. Alternatively, you can specify existing network interfaces when you launch instances.
Note
You can attach a network interface that's in another VPC (but in the same Availability Zone)
to an instance using the attach-network-interface
If the public IPv4 address on your instance is released, it does not receive a new one if there is more than one network interface attached to the instance. For more information about the behavior of public IPv4 addresses, see Public IPv4 addresses.
To attach a network interface to an instance using the command line
You can use one of the following commands. For more information about these command line interfaces, see Access Amazon EC2.
-
attach-network-interface (AWS CLI)
-
Add-EC2NetworkInterface (AWS Tools for Windows PowerShell)
Detach a network interface
You can detach a secondary network interface that is attached to an EC2 instance at any time, using either the Instances or Network Interfaces page of the Amazon EC2 console.
If you try to detach a network interface that is attached to a resource from another service, such as an Elastic Load Balancing load balancer, a Lambda function, a WorkSpace, or a NAT gateway, you get an error that you do not have permission to access the resource. To find which service created the resource attached to a network interface, check the description of the network interface. If you delete the resource, then its network interface is deleted.
To detach a network interface using the command line
You can use one of the following commands. For more information about these command line interfaces, see Access Amazon EC2.
-
detach-network-interface (AWS CLI)
-
Dismount-EC2NetworkInterface (AWS Tools for Windows PowerShell)