Skip to end of metadata
Go to start of metadata

Add / Remove a Virtual Network Interface Card from an Instance

You can now add a secondary (or more) virtual NICs to your instance with the "manage-instance" tool.  The "add-nic" command adds a network interface card (NIC) with a specified IP address to the instance.
Please note:

  • A virtual NIC can be applied to "running" or "offline" instances only.
  • In order to use a secondary network device on your instance, you must configure the NIC after creating it.  Instructions are below.
  • You must use the --force optional parameter to use a reserved IP address.
  • The remove-nic command removes a NIC with specified IP address from instance.  Please make sure the NIC is not in use before removing it from instance. Details are below.

Usage examples:

manage-instance add-nic --instance-id NYM1:417 --ip 8.12.226.192 --username <USERNAME>
manage-instance remove-nic --instance-id NYM1:417 --ip 8.12.226.192 --username <USERNAME>

Change the IP Address of an Interface

You can change the IP address of an interface with the "manage-instance modify-nic" command. There is no need to have two network interfaces on an instance to run this command.

Please note:

  • The instance must be shut down before you can run this command.
  • You must use "--force" optional parameter to assign a previously reserved IP address (via "manage-vlan reserve" command). In common case you can use any available for your VLAN IP ( issuie "manage-vlan list" command to list all your IPs).
  • Before you can change the IP for an interface, the interface must have a configfile. See the section Configure a New Networking Interface below.

Usage example:

manage-instance modify-nic --instance-id NYM1:417 --from-ip 8.12.226.192 --to-ip 8.12.226.29 --username <USERNAME>

Configure a New Networking Interface for Use by the Operating System

After adding a new virtual network interface card (NIC) to an instance with the "manage-instance add-nic" command, you must ask your instance's operating system to recognize it. This "activation process" fetches the settings for a new NIC from the DHCP server.  We strongly recommend not doing this manually, but instead creating a NIC configuration file.  The configuration file will allow DHCP harvesting for a new NIC automatically after an instance restart.

New NIC activation sequence

First SSH to the instance where you wish to activate a network interface, then follow the relevant instructions below.

CentOS

If you have launched the instance from our standard CentOS5-based image or from your custom image based on a CentOS-like system, then create a file /etc/sysconfig/network-scripts/ifcfg-eth1 (or ...ethN with N > 1 if you create many interfaces on the same instance) with the following contents:

DEVICE=eth1
BOOTPROTO=dhcp
DHCPCLASS=
ONBOOT=yes

Instruct every interface to use its own subnet in Address Resolution Protocol (ARP) requests by opening the /etc/sysctl.conf file and adding the following:

net.ipv4.conf.all.arp_announce=1

and then issue the "ifup eth1" command.

Debian

The only difference for Debian Linux is in adding networking interfaces. Open file /etc/network/interfaces and add the following lines for every additional interface you are setting up (eth1, eth2, ethN, ...):

auto eth1
iface eth1 inet dhcp

Other Linux OS

If you have launched an instance from your custom non-CentOS-like image, then perform the necessary steps to instruct the operating system to fetch DHCP settings for the newly appeared interface eth1, and bring this interface up.

Other OS

Unfortunately adding/deleting virtual network interfaces are supported on Linux instances only for now.  Our API team is working on adding this feature to the Windows CLI.

Delete an Existing Network Interface

Precautions

Deleting a NIC ("manage-instance remove-nic") is allowed for a running instance, although we recommend taking the instance offline first for simplicity. This is because the instance will define one of the interfaces as the default interface, used to transfer outgoing traffic from the instance. Each activation will transfer the "default route" setting to the latest activated interface. However, the DHCP interface configuration facility causes a re-configuration of interfaces periodically independent of instance restart, so the default interface is not always predictable.

If you remove the default interface from a running instance, any other interfaces become unavailable. For this reason, we recommend taking your instance offline before removal.

To delete a NIC from a running instance, you can avoid losing connectivity after deleting one of the NICs by making sure that the default connectivity route is assigned to the NIC that will remain on the instance after another NIC(s) deletion.

To do this, please:

  • SSH to instance.
  • Issue "dhclient ethN" command, using any interface that will remain on the instance after removing others.

After removing a NIC,  we advise not deleting its config file until after the next instance restart, because after a restart all VNICs will become renumbered so that they will form uninterrupted sequence starting with 0.

For example, if you have created 5 NICs on an instance, and then removed NICs #0, #1 and #3, you will get VNICs #2 and #4 remaining.  After an instance restart,  these NICs will be numbered as #0 and #1.  If you've deleted the configfiles for interfaces #0, #1 and #3 after NIC deletion, your instance will not be available, because renumbered interfaces #0 and #1 could not find their configfiles.

To avoid this:

  • Don't touch configfiles after interfaces deletion.
  • After instance restart, SSH to it and check what VNICs are in effect for this instance by issuing command "/sbin/ifconfig".
  • When you are absolutely sure which VNICs exists on the instance after restart, you may delete configfiles for non-existent VNICs.
  • No labels