The first IPv4 address assigned to a network interface is known as the primary IP address. Secondary IP addresses are additional IPv4 address assigned to a network interface. For more information, see Multiple IP addresses.
You can also assign multiple IPv6 addresses to an instance. For more information, see Manage the IPv6 addresses for your EC2 instances.
Assign secondary IP addresses to an instanceYou can assign secondary IP addresses to the network interface for an instance as you launch the instance, or after the instance is running.
Follow the procedure to launch an instance. When you configure Network Settings, expand Advanced network configuration.
For Secondary IP, choose Automatically assign and enter the number of IP addresses for Amazon EC2 to assign. Alternatively, choose Manually assign and enter the IPv4 addresses.
Complete the remaining steps to launch the instance.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Instances.
Select your instance, and choose Actions, Networking, Manage IP addresses.
Expand the network interface.
To add an IPv4 address, under IPv4 addresses, choose Assign new IP address. Enter an IPv4 address from the range of the subnet, or leave the field blank to let Amazon EC2 choose one for you.
Choose Save.
Use the run-instances command with the --secondary-private-ip-addresses
option.
--secondary-private-ip-addresses 10.251.50.12
To let Amazon EC2 choose the IP address, use the --secondary-private-ip-address-count
option instead. The following example assigns one secondary IP address.
--secondary-private-ip-address-count 1
Alternatively, you can create a network interface. For more information, see Create a network interface for your EC2 instance.
To assign a secondary IP address after launchUse the assign-private-ip-addresses command with the --private-ip-addresses
option.
aws ec2 assign-private-ip-addresses \
--network-interface-ids eni-1234567890abcdef0
\
--private-ip-addresses 10.251.50.12
To let Amazon EC2 choose the IPv4 address, use the --secondary-private-ip-address-count
parameter instead. The following example assigns one IPv4 address.
aws ec2 assign-private-ip-addresses \
--network-interface-ids eni-1234567890abcdef0
\
--secondary-private-ip-address-count 1
You must create a network interface. For more information, see Create a network interface for your EC2 instance.
To assign a secondary IP address after launchUse the Register-EC2PrivateIpAddress cmdlet with the -PrivateIpAddress
parameter.
Register-EC2PrivateIpAddress `
-NetworkInterfaceId eni-1234567890abcdef0
`
-PrivateIpAddress 10.251.50.12
To let Amazon EC2 choose the IPv4 addresses, use the -SecondaryPrivateIpAddressCount
parameter instead. The following example assigns one IPv4 address.
Register-EC2PrivateIpAddress `
-NetworkInterfaceId eni-1234567890abcdef0
`
-SecondaryPrivateIpAddressCount 1
After you assign a secondary IP address to your instance, you must configure the operating system on your instance to recognize the additional private IPv4 address.
Linux instancesIf you are using Amazon Linux, the ec2-net-utils package can take care of this step for you. It configures additional network interfaces that you attach while the instance is running, refreshes secondary IPv4 addresses during DHCP lease renewal, and updates the related routing rules. You can immediately refresh the list of interfaces by using one of the following commands, depending on your system: sudo systemctl restart systemd-networkd
(AL2023) or sudo service network restart
(Amazon Linux 2). You can view the up-to-date list using the following command: ip addr li
. If you require manual control over your network configuration, you can remove the ec2-net-utils package. For more information, see Configure your network interface using ec2-net-utils.
If you are using another Linux distribution, see the documentation for your Linux distribution. Search for information about configuring additional network interfaces and secondary IPv4 addresses. If the instance has two or more interfaces on the same subnet, search for information about using routing rules to work around asymmetric routing.
For more information, see Configure secondary private IPv4 addresses for Windows instances.
Unassign a secondary IP address from an instanceIf you no longer require a secondary IP address, you can unassign it from the instance or the network interface. When a secondary private IPv4 address is unassigned from a network interface, the Elastic IP address (if it exists) is also disassociated.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Instances.
Select an instance, choose Actions, Networking, Manage IP addresses.
Expand the network interface. For IPv4 addresses, choose Unassign for the IPv4 address to unassign.
Choose Save.
Use the unassign-private-ip-addresses command.
aws ec2 unassign-private-ip-addresses \
--network-interface eni-1234567890abcdef0
\
--private-ip-addresses 10.251.50.12
Use the Unregister-EC2PrivateIpAddress cmdlet.
Unregister-EC2PrivateIpAddress `
-NetworkInterface eni-1234567890abcdef0
`
-PrivateIpAddress 10.251.50.12
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4