Oracle Cloud Infrastructure Documentation

oci-network-config

Description

Configures network interfaces for an Oracle Cloud Infrastructure Compute instance.

Warning

Avoid entering confidential information when assigning descriptions, tags, or friendly names to your cloud resources through the Oracle Cloud Infrastructure Console, API, or CLI.

Usage

oci-network-config [-h] [-s] [--create-vnic] [--detach-vnic VNIC] [--add-private-ip]

[--del-private-ip ip_address] [--private-ip ip_address] [--subnet subnet] [--vnic-name name]

[--assign-public-ip] [--vnic OCID] [-a] [-d] [-e ip_address] [-n format]

[-r] [-X | --exclude item] [-I | --include item] [--quiet]

Options

-s | --show

Show information on all provisioning and interface configuration. This is the default action if no options are given.

--create-vnic

Create a new virtual network interface card (VNIC) and attach it to this instance.

--detach-vnic OCID

Detach and delete the VNIC with the given Oracle Cloud Identifier (OCID) or primary IP address. Cannot be the primary VNIC for the instance.

--add-private-ip OCID

Add a secondary private IP to an existing VNIC.

--del-private-ip ip_address

Delete the secondary private IP address with the given IP address.

--private-ip ip_address

Assign the given private IP address to the VNIC. Used with the with the --create-vnic and add-private-ip options,

--subnet subnet

Used with the with the --create-vnic option. Connects the new VNIC to the specified subnet.

--vnic-name name

Used with the with the --create-vnic option. Display name for the new VNIC.

--assign-public-ip

When used with the --create-vnic option, assign a public IP address to the new VNIC.

--vnic OCID

When used with the --add-private-ip option, assign the private IP address to the given VNIC

-a | --auto | -c | --configure

Add IP configuration for VNICs that are not configured and delete IP configuration for VNICs that are no longer provisioned.

-d | --deconfigure

Deconfigure all VNICs (except the primary). If used with the -e option, only the secondary IP addresses are deconfigured.

-e ip_address VNIC_OCID

Secondary private IP address to configure or deconfigure. Used with --configure and --deconfigure options.

-n | -ns format

When configuring, place interfaces in namespace identified by the given format. Format can include $nic and $vltag variables.

-r | --sshd

Start sshd in namespace (if -n is present).

-X | --exclude item

Persistently exclude the given item from automatic configuration or deconfiguration. Use the --include option to include the item again.

-I | --include item

Include an item that was previously excluded using the --exclude option in automatic configuration/deconfiguration.

-q | --quiet

Do not display information messages.

-h | --help

Displays a summary of the command line options.

Examples

Displaying current network configuration

Running the oci-network-config command with no options returns the network configuration of the current instance:

VNIC configuration for instance my-test-instance-20180622-1222

VNIC 1 (primary): my-test-instance-20180622-1222
Hostname: my-test-instance-20180622-1222
OCID: ocid1.vnic.oc1.phx.abcdefg12345678
MAC address: 00:00:17:00:F4:3F
Public IP address: 129.146.110.62
Subnet: Public Subnet cumS:PHX-AD-1 (10.0.0.0/24)


Operating System level network configuration

CONFIG ADDR            SPREFIX         SBITS VIRTRT          NS         IND IFACE      VLTAG VLAN        STATE MAC               VNIC
-      10.0.0.3        10.0.0.0        24    10.0.0.1        -          0   ens3       -     -           UP    00:00:17:00:f4:3f ocid1.vnic.oc1.phx.abcdefg12345678

Creating a new VNIC

This example creates a new VNIC named MY_NEW_VNIC and attaches it to the instance:

# sudo oci-network-config --create-vnic --vnic-name MY_NEW_VNIC
Info: creating VNIC: 10.0.0.4

Running oci-network-config with the -s option shows information for the new VNIC:

# sudo oci-network-config -s
VNIC configuration for instance scottb-instance-20180622-1222

VNIC 1 (primary): scottb-instance-20180622-1222
Hostname: scottb-instance-20180622-1222
OCID: ocid1.vnic.oc1.phx.abcdefg12345678
MAC address: 00:00:17:00:F4:3F
Public IP address: 129.146.110.62
Subnet: Public Subnet cumS:PHX-AD-1 (10.0.0.0/24)

VNIC 2: MY_NEW_VNIC
Hostname: scottb-instance-20180622-1222-mynewvnic
OCID: ocid1.vnic.oc1.phx.abcdefg12345678
MAC address: 00:00:17:00:27:A7
Public IP address: None
Subnet: Public Subnet cumS:PHX-AD-1 (10.0.0.0/24)


Operating System level network configuration

CONFIG ADDR            SPREFIX         SBITS VIRTRT          NS         IND IFACE      VLTAG VLAN        STATE MAC               VNIC
-      10.0.0.3        10.0.0.0        24    10.0.0.1        -          0   ens3       -     -           UP    00:00:17:00:f4:3f ocid1.vnic.oc1.phx.abcdefg12345678
-      10.0.0.4        10.0.0.0        24    10.0.0.1        -          1   ens4       -     -           UP    00:00:17:00:27:a7 ocid1.vnic.oc1.phx.abcdefg12345679

Detaching a VNIC

To detach a VNIC from the instance, use the --detach-VNIC option. Note that the given VNIC cannot be the primary VNIC for the instance:

sudo oci-network-config --detach-vnic 00:00:17:00:27:A7