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.

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.

Step 3: Review Additional Subnet Details

  • In the Additional Subnet Details tab, you can configure advanced networking options.

  • Click Next to continue.

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 to learn how to create a router.

  • Once selected, click Submit to finalize VPC creation.

b. Create a Virtual Machine (VM)

Step 1: Enter the basic details, and in the Network settings, select the created VPC. (Click here to learn how to make a VM.)

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

c. Reserve and Associate a Floating IP

Step 1: Associate a floating IP with the instance

Click here 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.

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.

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.

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.

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:

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.

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.

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.

Last updated

Was this helpful?