How can I assign a static IP address to my Amazon EC2 Windows instance?

Last updated: 2022-05-05

I use an Amazon Elastic Compute Cloud (Amazon EC2) Windows instance, and a private IP address is automatically assigned to the instance. Can I assign a static IP address to my Amazon EC2 Windows instance?

Resolution

Static private IP addresses aren't required for Amazon EC2 Windows instances. However, you can use two private IP addresses for your Windows network adapter. To assign a static private IP address for an Amazon EC2 Windows instance, follow these steps:

Note: The network interface IP address and Windows adapter IP addresses must match for a successful network connection.

  1. Open the Amazon EC2 console, and then choose Instances from the navigation pane.
  2. Select your instance. From the Networking tab, Expand Network interfaces, and then choose the Interface ID.
  3. Select the Network interface ID, Choose Actions, and then choose Manage IP Addresses. The primary private IPv4 IP address is already listed.
  4. Expand the network interface ID, and then choose Assign new IP address.
  5. Do one of the following:
    For Auto-assign, enter a new IP address, and then choose Save.
    -or-
    Don't enter a new IP address, choose Save, and then choose Confirm to auto assign the new IP address to the network interface.
    Important: Note the primary private IPv4 address and the new IP address for a later step.
  6. Connect to your Amazon EC2 Windows instance using Remote Desktop Protocol (RDP).
  7. Open a command prompt window as an administrator, type ipconfig/all, and then press the enter key. Note the IP address, Subnet mask, and Default gateway.
  8. Open Network and Sharing Center, and then choose Change adapter settings.
  9. Open the context menu for the network connection, and then choose Properties.
  10. Select Internet Protocol Version 4 (TCP/IPv4), and then choose Properties.
  11. Choose Use the following IP address.
    For IP address, enter the primary private IPv4 address.
    For Subnet mask, enter the network mask for the subnet.
    For Default gateway, enter the gateway for the subnet.
    Choose Advanced.
  12. For IP addresses, choose Add. Enter the new private IP address and subnet mask, and then choose Add.
  13. (Optional) Choose the DNS tab, enter a DNS server address, and then choose OK.
    Note: For more information about finding your VPC DNS server settings, see Amazon DNS server. For information about reserved addresses, see Subnet sizing.

To verify that the new IP address is successfully added, open a command prompt window as an administrator and ping both private IP addresses. You can also ping both addresses from another instance in the same subnet.