How to configure a second NIC on OCI¶
WHAT TO EXPECT
In this article, users will learn how to configure a second NIC in OCI so it can be used with xNIC or cloudSwXtch
OCI Firewall rules and netplan¶
The default configuration for a VM created in OCI using the web console usually comes with only one NIC and with the firewall rules blocking xNIC traffic.
Set Firewall iptables rules for OCI¶
Confirm that your iptables rules for your distro are allowing both xNIC and cloudSwXtch, control and data traffic to flow. The following is a sample iptables config that allows all traffic within a subnet CIDR range to flow.
-
Using
sudo, add the following rules specifying your control and data CIDR ranges to the/etc/iptables/rules.v4file, just before the-A INPUT -j —rejectwith icmp-host-prohibited rule.-A INPUT -p all -s <your Control Subnet IP Address>/<mask> -j ACCEPT -A INPUT -p all -s <your Data Subnet IP Address>/<mask> -j ACCEPTUsers should replace the CIDRs with the correct CIDRs of the working environment, corresponding to the control and data subnets. These numbers can be the same if using a single-subnet configuration for both your VNICs.
-
Save the file and reboot the instance.
PLEASE NOTE
xNIC Type 1 (using swx0) requires a third, similar rule for its subnet; example:
Set DHCP in netplan for OCI 2nd NIC on Linux¶
If the VM needs a second NIC for data-plane, OCI will not automatically configure an IP for the adapter using DHCP.
In order to configure the IP for the second adapter, users can execute the following instructions.
Prior to executing any instructions, users need to know two parameters assigned by OCI to the secondary NIC:
- IP Address
- MAC Address
These values are available in the OCI console. To get them:
- Go to the console
- Go to Instances
- Click on the desired instance
- Click the Networking tab
- Click the name of the secondary NIC in the Attached VNICs section
- Take note of the MAC Address and the Private IP address fields

Now, with that information, follow the instructions based on the OS of the VM.
Debian-based distros¶
-
Create a file called
02-datanic-static-config.yamlin the/etc/netplanfolder.network: version: 2 ethernets: ens4: match: macaddress: "<ADD macaddress of primary of 2nd VNIC>" dhcp4: false addresses: - <ADD Primary IP ADDRESS OF 2ND VNIC>/<XX>Where the
is the net mask (or network mask) of ctrl-plane CIDR (in single-subnet configuration). Example: -
Run the following command to apply the changes:
RHEL-based distros¶
-
Create a file called
ifcfg-ens4in the/etc/sysconfig/network-scriptsfolder:PLEASE NOTE
The file owner has to be root:root
-
Apply changes:
-
CentOS 7/RHEL7
-
CentOS 8/RHEL 8/9:
-
Windows¶
- Navigate to Control Panel→Network and Internet→Network and Sharing Center
- Select the 2nd NIC to open Properties.
- Select Internet Protocol Version 4 (TCP/IPv4)
- Enter the IP Address, Subnet Mask, and Default gateway data.
