Aniket Singh
Aniket Singh

Reputation: 877

How to assign two IP address to single virtual machine in Azure

I installed a software called Postal on my azure virtual machine, now I have 1 public IP address but the application requires an another IP so that it can enable fast_server and use that new IP to track all links.

I tried adding new ip by

  1. Open Network Interface of that Virtual Machine
  2. Click on IP Configuration
  3. Click on Add button and add that IP as secondary

I have got the secondary IP but It's not properly working or responding.

Do I have to enable any inbound rule for that IP?

Upvotes: 1

Views: 4462

Answers (1)

Sa Yang
Sa Yang

Reputation: 9401

After associating a Public address resource to a new IP configuration or an existing IP configuration, you still need to add the private IP addresses to your VM OS.

Review the new IP configuration. Even though a private IP address wasn't explicitly assigned, one was automatically assigned to the IP configuration, because all IP configurations must have a private IP address.

SSH your Azure Linux VM and Complete the following steps for your VM operating system (Ubuntu):

  1. Make sure you are the root user. If you are not, enter the following command:sudo -i

  2. Update the configuration file of the network interface (assuming ‘eth0’).

    Keep the existing line item for dhcp. The primary IP address remains configured as it was previously.

    Add a configuration for an additional static IP address with the following commands: cd /etc/network/interfaces.d/ ls

    You should see a .cfg file

  3. Open the file. You should see the following lines at the end of the file auto eth0 iface eth0 inet dhcp

  4. Add the following lines after the lines that exist in this file: iface eth0 inet static address <your private IP address here> netmask <your subnet mask>

NOTE:Add each of the secondary private IP addresses to the NIC with the same subnet specified for the primary IP address.

  1. Save the file by using the following command::wq

  2. Reset the network interface with the following command:sudo ifdown eth0 && sudo ifup eth0

Important

Run both ifdown and ifup in the same line if using a remote connection.

  1. Verify the IP address is added to the network interface with the following command:ip addr list eth0

    You should see the IP address you added as part of the list.

You can see more details about how to Assign multiple IP addresses to virtual machines using the Azure portal in this official document. Please let me know if it helps.

Upvotes: 2

Related Questions