Assigning a New Secondary Private IP to a VNIC

Assign a new secondary private IP address to a VNIC.

Note

Using the CLI or API, you can also assign more than one secondary private IP to a VNIC with a single command.

You can add a secondary private IP to an instance after it's created. You can add it to either the primary VNIC or a secondary VNIC on the instance. The secondary private IP address must come from the CIDR of the VNIC's subnet. You can move a secondary private IP from a VNIC on one instance to a VNIC on another instance if both VNICs belong to the same subnet.

For more information see Private IP Addresses.

    1. Open the navigation menu  and select Compute. Under Compute, select Instances.
    2. Select the compartment that contains the instance you want to add a private IP address to.
    3. Select the name of the instance to open its details page.
    4. On the Networking tab, go to the Attached VNICs section and select the VNIC that you're interested in.
    5. On the IP administration tab:
      • For IPv4 addresses, select Assign secondary private IP address and then enter the private IPv4 address information:

        • IPv4 Address: (Optional) Select an IPv4 CIDR block to automatically assign the prefix to allocate the private IP object. The available choices depend on the other selections.
        • Automatically assign IPv4 addresses: Select this option to let the Console assign an available IPv4 address from an IPv4 CIDR assigned to this subnet. A subnet can have more than one IPv4 prefix.
        • Manually assign IPv4 address: Select this option to use a specific address from an IPv4 CIDR block assigned to this subnet.
        • Private IP address: (Optional) Enter an available private IP address from the subnet's CIDR block. If you leave this field blank, the Console assigns a private IP address automatically.
        • CIDR prefix length: (Optional) Enter an IPv4 network mask length to assign an IP range address. If you leave this field blank, the system creates a host IP address.
        • Unassign if already assigned to another VNIC: Select this option to force reassignment of the IP address if it's already assigned to another VNIC in the subnet. Only relevant if you specify a private IP address in the preceding field.
        • Hostname: (Optional) A hostname to use for DNS within the cloud network. This field is available only if both the VCN and subnet have DNS labels. See DNS in a Virtual Cloud Network. This field is unavailable if the CIDR prefix length is used in the range of 18 to 31.
        • Public IP Type: (Optional) Only available for IPv4 and if the VNIC is in a public subnet. See Public IP Addresses. This field is unavailable if CIDR prefix length is used in the range of 18 to 31.
      • For IPv6 addresses, select Assign IPv6 Address and then enter the private IP address information:

        • Subnet IPv6 Prefix: (Optional) Select an IPv6 prefix to automatically assign the prefix to allocate the private IP object. The available choices depend on the other selections.
        • Automatically assign IPv6 addresses: Select this option to let the Console assign an available IPv6 address from an IPv6 prefix assigned to this subnet. A subnet can have more than one IPv6 prefix.
        • Manually assign IPv6 address: Select this option to use a specific address from an IPv6 prefix assigned to this subnet.
        • Private IP address: (Optional) Enter an available private IP address from the subnet's CIDR block. If you leave this field blank, the Console assigns a private IP address automatically.
        • CIDR prefix length: (Optional) Enter an IPv6 network mask length to assign an IP range address. If you leave this field blank, the system creates a host IP address.
        • Unassign if already assigned to another VNIC: Select this option to force reassignment of the IP address if it's already assigned to another VNIC in the subnet. Only relevant if you specify a private IP address in the preceding field.
        • Hostname: (Optional) A hostname to use for DNS within the cloud network. This field is available only if both the VCN and subnet have DNS labels. See DNS in a Virtual Cloud Network. This field is unavailable if the CIDR prefix length isn't a host mask (/128).
      • Route Table: (Optional) Assign a custom route table to handle traffic from this IP address. For more information, see Per-resource Routing.

        If you assign a custom route table, traffic from this IP address doesn't use the default VCN or subnet route tables.

    6. To assign more IP address objects to the instance VNIC, select Another IPv4 address/+ Another subnet prefix. If you're attaching this VNIC to an existing instance after creation, ensure that the instance's operating system is configured to use IPv4 addressing.
    7. Select Assign.
  • Use the network vnic assign-private-ip command and required parameters to assign a secondary private IP to a VNIC:

    oci network vnic assign-private-ip --ip-address IP_address --unassign-if-already-assigned VNIC_OCID
    --vnic-id destination_VNIC_OCID ... [OPTIONS]

    Optionally, use the network private-ip bulk-create command and required parameters to assign more than one secondary private IPv4 address to a VNIC with a single command.

    oci network private-ip bulk-create --unassign-if-already-assigned VNIC_OCID
     --from-json file:// ... [OPTIONS]

    For a complete list of parameters and values for CLI commands, see the CLI Command Reference.

  • Run the CreatePrivateIp operation to assign a new secondary private IP to a VNIC.

    Optionally, run the BulkCreatePrivateIps operation to assign more than one secondary private IP to a VNIC within a single API call.