Assigning a New Secondary Private IP to a VNIC

Assign a new secondary private IP address to a VNIC.

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. Under List scope, 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. Under Resources, select Attached VNICs.
    5. Select the VNIC that you're interested in.
    6. Under Resources, select IPv4 Addresses.
    7. Select Assign Secondary Private IP Address and then enter the private IP address information:
      • IPv4 Address (Optional): Select an IPv4 CIDR block to automatically assign the IPv4 address. The available choices depend on what you select in IPv4 Address Assignment.

        • Automatically assign IPv4 addresses from prefix: 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 addresses: 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 left blank, the Console assigns a private IP address automatically.

        • CIDR Prefix Length (Optional): Enter an IPv4 network mask length to assign an IP CIDR address. If you leave this field blank, the system creates a host IP address.

        • Unassign if already assigned to another VNIC: Select this checkbox 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. Only available if both the VCN and subnet have DNS labels. See DNS in a Virtual Cloud Network. This field is unavailable if CIDR prefix length is used in the range of 18-31.
        • Public IP Type: (Optional) Only available 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-31.
      • 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.

        If you select + Another IPv4 address, you can assign additional IPv4 objects to the instance VNIC. 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.

    8. 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]

    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.