19 IP Network

This section describes the Compute Classic CLI commands you can use to add, delete, update, and view IP networks.

An IP network allows you to define an IP subnet in your account. The size of the IP subnet and the set IP addresses in the subnet are determined by the IP address prefix that you specify while creating the IP network. These IP addresses aren't part of the common pool of Oracle-provided IP addresses used by the shared network. When you attach an instance to an IP network (by specifying the network in the instance launch plan), the instance is assigned an IP address in that subnet. You can assign IP addresses to instances either statically or dynamically, depending on your business needs. So you have complete control over the IP addresses assigned to your instances. For more information, see Managing IP Networks in Using Oracle Cloud Infrastructure Compute Classic.

Before running the CLI commands described in this section, make sure that you've installed the CLI client and set up the required environment variables as described in Preparing to Use the CLI.

ip-network add

Creates an IP network. An IP network allows you to define an IP subnet in your account. With an IP network you can isolate instances by creating separate IP networks and adding instances to specific networks. Traffic can flow between instances within the same IP network, but by default each network is isolated from other networks and from the public Internet.

Required Role

To complete this task, you must have the Compute_Operations role. If this role isn’t assigned to you or you’re not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute ip-network add name ip-address-prefix [--ipnetworkexchange IP-network-exchange] [--description description] [--tags tags] 

For help with the parameters and options of this command, run the command with the -h option.

Example

opc -f json compute ip-network add /Compute-acme/jack.jones@example.com/ipnet1 192.168.0.0/24  

Sample Output

 {
  "uri": "https://api-z999.compute.us0.oraclecloud.com:443/network/v1/ipnetwork/Compute-acme/jack.jones@example.com/ipnet1",
  "ipNetworkExchange": null,
  "ipAddressPrefix": "192.168.0.0/24",
  "name": "/Compute-acme/jack.jones@example.com/ipnet1"
 }

ip-network list

Retrieves details of all the IP networks in the specified container.

Required Role

To complete this task, you must have the Compute_Monitor or Compute_Operations role. If this role isn’t assigned to you or you’re not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute ip-network list container 

For help with the parameters and options of this command, run the command with the -h option.

Example

opc -f json compute ip-network list /Compute-acme/jack.jones@example.com

Sample Output

{
 "result": [
 {
  "uri": "https://api-z999.compute.us0.oraclecloud.com:443/network/v1/ipnetwork/Compute-acme/jack.jones@example.com/ipnet1",
  "ipNetworkExchange": null,
  "ipAddressPrefix": "192.168.0.0/24",
  "name": "/Compute-acme/jack.jones@example.com/ipnet1"
 }
]
}

ip-network get

Retrieves details of the specified IP network.

You can use the get command to verify whether add and update operations were completed successfully.

Required Role

To complete this task, you must have the Compute_Monitor or Compute_Operations role. If this role isn’t assigned to you or you’re not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute ip-network get name 

For help with the parameters and options of this command, run the command with the -h option.

Example

opc -f json compute ip-network get /Compute-acme/jack.jones@example.com/ipnet1

Sample Output

{
  "uri": "https://api-z999.compute.us0.oraclecloud.com:443/network/v1/ipnetwork/Compute-acme/jack.jones@example.com/ipnet1",
  "ipNetworkExchange": null,
  "ipAddressPrefix": "192.168.0.0/24",
  "name": "/Compute-acme/jack.jones@example.com/ipnet1"
}

ip-network update

You can update an IP network and change the specified IP address prefix for the network after you've created the network and attached instances to it. However, when you change an IP address prefix, it could cause the IP addresses currently assigned to existing instances to fall outside the specified IP network. If this happens, all traffic to and from those vNICs will be dropped.

If the IP address of an instance is dynamically allocated, stopping the instance orchestration and restarting it will reassign a valid IP address from the IP network to the instance.

However, if the IP address of an instance is static - that is, if the IP address is specified in the instance orchestration while creating the instance - then the IP address can't be updated by stopping the instance orchestration and restarting it. You would have to manually update the orchestration to assign a valid IP address to the vNIC attached to that IP network.

It is therefore recommended that if you update an IP network, you only expand the network by specifying the same IP address prefix but with a shorter prefix length. For example, you can expand 192.168.1.0/24 to 192.168.1.0/20. Don't, however, change the IP address. This ensures that all IP addresses that have been currently allocated to instances remain valid in the updated IP network.

Required Role

To complete this task, you must have the Compute_Operations role. If this role isn’t assigned to you or you’re not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute ip-network update name ipaddressprefix [--ip-network-exchange ip-Network-Exchange] [--description description] [--tags tags] 

For help with the parameters and options of this command, run the command with the -h option.

Example

This command updates the IP address prefix of the /Compute-acme/jack.jones@example.com/ipnet1 IP network from 192.168.0.0/24 to 192.168.0.0/20 and adds the IP network to the specified IP network exchange.

opc -f json compute ip-network update --ip-network-exchange /Compute-acme/jack.jones@example.com/ipexchange1 /Compute-acme/jack.jones@example.com/ipnet1 192.168.0.0/20 

Sample Output

{
  "uri": "https://api-z999.compute.us0.oraclecloud.com:443/network/v1/ipnetwork/Compute-acme/jack.jones@example.com/ipnet1",
  "ipNetworkExchange": "/Compute-acme/jack.jones@example.com/ipNetworkExchange1",
  "ipAddressPrefix": "192.168.0.0/20",
  "name": "/Compute-acme/jack.jones@example.com/ipnet1"
 }

ip-network delete

Deletes the specified IP network. No response is returned.

If you delete an IP network that contains instances, the packets sent across the instances within the IP network are dropped.

Required Role

To complete this task, you must have the Compute_Operations role. If this role isn’t assigned to you or you’re not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Syntax

opc compute ip-network delete name

For help with the parameters and options of this command, run the command with the -h option.

Example

opc compute ip-network delete /Compute-acme/jack.jones@example.com/ipnet1