# How to Attach Multiple Interfaces to an Instance?

To Attach Multiple Interfaces to an Instance, follow the steps below:

### a. Create a Virtual Private Cloud (VPC)

**Step 1: Go to Networks, choose VPC, and click Create VPC.**

<figure><img src="/files/TiNebhmGBmABRIAdk5bu" alt=""><figcaption></figcaption></figure>

**Step 2:** **Enter VPC and Subnet Details**

* **VPC Name**: Provide a name for your VPC. This name will help you identify the VPC later when managing network resources.
* **Subnet Name**: Enter a name for your first subnet. Subnets divide your VPC's IP range into smaller, manageable blocks.
* **IP Version**: Choose the IP version — usually **IPv4** is selected unless you specifically require IPv6.
* **Subnet (CIDR Block)**: Enter the CIDR block for the subnet, e.g., `192.168.0.0/24`. This defines the IP address range within the subnet.
* **Gateway IP**: Specify the gateway IP for the subnet, which acts as the exit point for traffic leaving the subnet.

> Ensure that the CIDR block and gateway IP do not overlap with other existing subnets in your account.

* After entering all details, click **Next** to proceed.

<figure><img src="/files/AquuQlXL7f557blzVgtS" alt=""><figcaption></figcaption></figure>

**Step 3:** **Review Additional Subnet Details**

* In the **Additional Subnet Details** tab, you can configure advanced networking options.
* Click **Next** to continue.

<figure><img src="/files/uAGBMAQU4Vd6RjJRKevy" alt=""><figcaption></figcaption></figure>

**Step 4: Select a Router and Submit**

* On the final screen, you will be asked to **select a Router**.
* Choose an existing router from the dropdown list. The router connects your subnet to the Internet or other networks.

> If no router is available, please create one in the **Router** section before proceeding. Click [here](https://docs.acecloudhosting.com/knowledge-base/network) to learn how to create a router.

* Once selected, click **Submit** to finalize VPC creation.

<figure><img src="/files/AFWcIiN3nGGIlTUpDDDe" alt=""><figcaption></figcaption></figure>

### b. Create a Virtual Machine (VM)

**Step 1**: **Enter the basic details, and in the Network settings, select the created VPC.** (*Click* [*here*](https://docs.acecloudhosting.com/knowledge-base/compute) *to learn how to make a VM.*)

<figure><img src="/files/SL0wprGNydL7JvsvHbCG" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}

### Note: Launch the VM after confirming network and security settings.&#xD; These configurations ensure the VM is securely deployed within the internal network&#xD; environment.

{% endhint %}

### c. Reserve and Associate a Floating IP

**Step 1: Associate a floating IP with the instance**

*Click* [*here*](https://docs.acecloudhosting.com/knowledge-base/compute/how-do-you-associate-disassociate-floating-ip-in-an-instance) *to know how to associate a Floating IP.*

Complete the actions below:

* Reserve Floating IP
* Map the Internal IP
* Associate Instance
* Status: Active
* Floating IP Pool: EXT-NOI

This step ensures that the VM can be accessed externally via the assigned floating IP.

### **d. Access the VM via SSH Using the Floating IP**

**Step 1: Establish a secure shell (SSH) connection to the virtual machine using the previously assigned floating IP.**

Connection Details:

* SSH Client Used: MobaXterm
* Remote Host (Public IP): 154.201.XXX.XX
* Username: ubuntu
* Authentication: Private key authentication enabled
* SSH Protocol Settings:
  * X11-Forwarding: Enabled
  * Compression: Enabled
  * Remote Environment: Interactive shell
  * SSH-browser Type: SFTP protocol

This step confirms successful remote access to the VM using the floating IP, completing the external connectivity setup.

<figure><img src="/files/Lofy4zzqBC4HWUTYxcR2" alt=""><figcaption></figcaption></figure>

**Step 2: Set the Root Password**

* Access the VM via SSH as the ubuntu user.
* Switch to the root user using sudo -i.
* Execute the passwd command.
* Set and confirm a new root password.

***Note:** This step is critical for administrative access and must be performed securely. Ensure the password is stored securely and adheres to strong password policies.*

<figure><img src="/files/ldnJcPViQUMQpjT91F03" alt=""><figcaption></figcaption></figure>

**Step 3: Attach a Second Interface with a Public IP**

This step prepares the VM for dual-interface operation, enabling both internal and external network communication.

<figure><img src="/files/qNdJsb28JubQ1MtqddOI" alt=""><figcaption></figcaption></figure>

### e. Create a Second Instance in a Private VPC and Test Internal Connectivity

Follow the actions below.

* Select the Instance, Region, and Image.
* Choose volume size, Flavor type, VPC, security groups, and key pair.

After launching the instance, use its private IP to test connectivity by pinging it from the first instance. This will confirm successful internal communication within the VPC environment.

<figure><img src="/files/36d48c36f2fb71c1f952f1d412e97afa4703e894" alt=""><figcaption></figcaption></figure>

**Step 1: Verify Interface Attachment and Test Internal Connectivity**

* Run the ip a command to list network interfaces
* Verify that both interfaces are active and configured.
* Ping Test: Ping the private IP of the second instance from the first instance to confirm internal connectivity.

This step validates the dual-interface setup and ensures that internal communication between instances is functioning correctly.

### f. Understanding and Disabling Cloud-Init for IP Configuration Stability

**What is Cloud-Init?**

Cloud-init is a widely used tool in cloud environments that automatically applies user data and metadata to instances during the boot process. It is responsible for:

1. Setting SSH Keys – Injects public keys for secure access.
2. Setting Hostname – Configures the system hostname.
3. Setting IP Addresses – Applies network configurations, often via DHCP or static settings defined in metadata.

**Why Disable Cloud-Init?**

If you manually configure network settings (e.g., static IPs), cloud-init can override these settings on reboot, especially after a hard reboot. This can disrupt connectivity and cause misconfigurations.

**Best Practice:** Disable or modify cloud-init after setting the root password and configuring the network manually to prevent it from reapplying default settings.

Configuration Example:

<figure><img src="/files/U1G3iHyDrtfJnxvAP0Mu" alt=""><figcaption></figcaption></figure>

This YAML configures:

* enp8s0.4 with a static IP (192.168.X.XXX/XX)
* A route via 192.168.X.X
* DNS servers: Cloudflare (1.1.1.1) and Google (8.8.8.8)

**Step 1: Remove Cloud-Init to Prevent Reconfiguration on Reboot**

* Execute the command:

```
apt remove cloud-init
```

* Confirm removal when prompted.
* Result: cloud-init package was successfully removed, freeing up 3 MB of disk space.

***Note**: Removing cloud-init ensures that it does not reapply default configurations (like IP settings or SSH keys) during future reboots, which is especially important after setting a static IP or root password.*

<figure><img src="/files/85c2625db44fd498e2d08d117f933e9cb5711536" alt=""><figcaption></figcaption></figure>

**Step 2: Apply Network Configuration with Netplan**

Execute the command:

```
sudo netplan apply 
```

This command applies the network configuration defined in the YAML file, ensuring that the static IP, routes, and DNS settings take effect immediately without requiring a reboot.

***Tip:** Always verify connectivity after applying Netplan using ip a, ping, or netplan try for safer testing.*

### g. Dual Interface Verification

**Step 1: Confirm that the primary instance has both private and public network interfaces attached.**

Verification:

* Instance: aayush1
* Status: Active
* Operating System: Ubuntu 24.04 LTS
* Interfaces Attached:
* Public IP: 154.201.XXX.XX
* Private IP: 192.186.X.X
* Instance: aayush2 (for internal communication testing)

This confirms that the dual-interface setup is complete and functioning as expected.

<figure><img src="/files/8VdJeJmKZkUHULePikwh" alt=""><figcaption></figcaption></figure>

**Step 2: Confirm Internal Connectivity via Ping**

Verify that the dual-interface setup allows internal communication between instances using their private IPs.

* Logged into the instance with private IP.
* Run the command:

```
ping -c 4
```

* Confirm the successful ping response to verify that the instance can reach another instance over the private network.

This will confirm that the internal networking is functioning correctly and both interfaces are active and properly configured.

<figure><img src="/files/zf4ObxCnglcXXDltBaU4" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.acecloud.ai/knowledge-base/tutorials/how-to-attach-multiple-interfaces-to-an-instance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
