Configure a multihomed VM with a static IP address to access an external database on an additional network.
Outcomes
Deploy the Kubernetes NMState operator.
Export the current network configuration for the cluster nodes.
Create a node network configuration policy to configure a Linux bridge on the compute nodes.
Observe the policy enactment on the compute nodes.
Configure a secondary interface on a VM to use the Linux bridge and a custom MAC address.
Confirm that the VM is connected to the additional network and is configured with a 192.168.51.10/24 static IP address.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start multihomed-nmstate
Instructions
A developer's VM needs access to a database outside your Red Hat OpenShift Container Platform cluster.
The database, on server.srv.example.com, is configured to accept incoming connections from the devuser user, from a specific IP address on the 192.168.51.0/24 network only.
The cluster nodes, worker01 and worker02, each have an additional ens4 interface, on the 192.168.51.0/24 network.
Use the Kubernetes NMState operator to configure the worker01 and worker02 nodes as multihomed nodes with an L2 Linux bridge on the ens4 interface.
After creating the Linux bridge on the compute nodes, create a network attachment definition to enable VMs within the developer-vms project to use the database network that the Linux bridge provides.
Next, configure the developer's VM to use this additional network as a secondary interface with a static IP address.
Confirm that the VM can communicate with the database on server.srv.example.com on the database network.
As the admin user, install the Kubernetes NMState operator.
Open a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com
Click and log in as the admin user with redhatocp as the password.
Click → .
In the field, type nmstate to locate the NMState operator, and then click .
![]() |
The web console displays information about the Kubernetes NMState operator. Click to proceed to the page.
![]() |
Click to install the operator with the default options in the openshift-nmstate namespace.
Wait until the installation is complete and the web console displays the ready for use message.
![]() |
Create an NMState instance.
After the operator installation completes, click .
Alternatively, you can navigate to → and open the page.
In the NMState card, click to view the creation parameters for the NMState instance.
![]() |
Ensure that the instance name is nmstate, and click at the lower left of the window.
Wait a few minutes until the web console shows the Web console update is available message, and then reload the web console.
![]() |
Verify that both and items are available in the menu.
![]() |
Observe and then back up the current node network configuration of the worker01 and worker02 nodes to YAML files.
The backup YAML files are for reference only, and cannot be applied to the cluster to modify or restore node networking to a previous state.
From the left panel of the OpenShift web console, navigate to → .
Observe the network configuration of the worker01 and worker02 nodes.
The ens4 network interface is connected to the same network as the database server.
![]() |
Click , navigate to the tab, and click to export the node network configuration as a YAML file.
![]() |
Repeat the operation for the worker02 node.
Add the external-network=true label to the worker01 and worker02 nodes.
You use this label as a node selector in later steps.
Navigate to → , click the vertical ellipsis icon next to the worker01 line, and then click .
![]() |
Type external-network=true in the form and click .
Repeat this step for the worker02 node.
On the → page, select in the drop-down menu, type external in the field, and select the external-network=true label.
![]() |
Verify that the node list contains only the worker01 and worker02 nodes.
![]() |
Create a node network configuration policy to configure a new Linux bridge with the ens4 ethernet device as the port.
Navigate to → and click .
Alternatively, you can click at the upper right and select .
Complete the form by using the following information to create the Linux bridge:
| Field | Value |
|---|---|
| Name | br0-ens4-policy |
| Description | Linux bridge with ens4 as a port |
| Interface name | br0 |
| Network state | Up |
| Type | Bridge |
| IPv4 | Checked |
| DHCP | Checked |
| Port | ens4 |
Select the checkbox to open the node selector.
![]() |
Click , and type external-network as the key, and true as the value.
Verify that both worker01 and worker02 nodes match that label configuration by clicking .
![]() |
Click and then click to create the node network configuration policy.
Monitor the progress of the configuration policy.
Navigate to → to review the status of the node network configuration policy.
Observe the br0-ens4-policy status and wait until the node network state is 2 Available.
![]() |
Click to review the status summary and confirm that the policy applies successfully on each node.
![]() |
Observe the network configuration of the worker01 and worker02 nodes, and confirm the configuration of the new Linux bridge.
Navigate to → , and notice the item on both worker01 and worker02 nodes.
Click and review the configuration summary of the Linux bridge.
The br0 bridge is connected to the same network as the database server.
![]() |
Click to display more details about the bridge configuration, and verify that the bridge port is ens4.
![]() |
The worker01 and worker02 nodes are now configured as multihomed nodes with an L2 Linux bridge that provides access to the database network.
Create a network attachment definition in the developer-vms project that uses the Linux bridge to attach VMs to the database network.
Navigate to → .
Select the developer-vms project from the list, and then click .
Complete the form by using the following information to create a network attachment definition for the database network:
| Field | Value |
|---|---|
| Name | database-network |
| Description | Linux bridge on the worker01 and worker02 nodes with ens4 as a port |
| Network Type | CNV Linux bridge |
| Bridge Name | br0 |
![]() |
Click to create the network attachment definition.
Configure the developer's VM to use the database network on a secondary interface.
Configure the secondary interface to use 00:00:00:00:00:01 as a custom MAC address.
The custom MAC address is required for the VM to receive the 192.168.51.10/24 static IP address from the DHCP server in the database network.
Navigate to → .
Select the developer-vms project from the list.
Click the VM to open the VM's tab.
Click the tab and then click to display the network interfaces that are connected to the VM.
Click to create an interface on the VM.
On the page, set the name to database and select from the field.
Confirm that the is set to Bridge, and enter 00:00:00:00:00:01 in the field.
Click to save and attach the interface to the VM.
![]() |
Restart the VM to apply the pending changes. Click → , and then click to confirm the action.
![]() |
Confirm that the VM's secondary network interface, eth1, is configured with a 192.168.51.10/24 static IP address.
Click the tab to open the VM's console.
Click the console window and log in as the developer user with developer as the password.
Use the ip addr show eth1 command to display the IP address configuration of the eth1 network interface.
[developer@dev-dbaccess ~]$ip addr show eth13: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:00:00:00:00:01 brd ff:ff:ff:ff:ff:ff inet192.168.51.10/24brd 192.168.51.255 scope global dynamic noprefixroute eth1 valid_lft 437230198sec preferred_lft 437230198sec inet6 fe80::b50f:3586:6165:c5a3/64 scope link noprefixroute valid_lft forever preferred_lft forever
Alternatively, you can observe the VM IPs on the tab, in the card.
![]() |
Connect to the sakila database on server.srv.example.com with the mysql client.
The host, server.srv.example.com, resolves with the server hostname to resources in the 192.168.51.0/24 network.
On the VM's console, use the mysql command to connect to the MariaDB instance on the server.srv.example.com host.
Log in as the devuser user with developer as the password.
[developer@dev-dbaccess ~]$mysql -u devuser -h server -pEnter password:developerWelcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.5.16-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
Connect to the sakila database with the use command.
MariaDB [(none)]> use sakila;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [sakila]>Confirm that the devuser can view the sakila tables with the show tables; command.
MariaDB [sakila]> show tables;
+------------------------------+
| Tables_in_sakila |
+------------------------------+
| actor |
| actor_info |
| address |
| category |
| city |
...output omitted...
| staff_list |
| store |
+------------------------------+
23 rows in set (0.002 sec)Exit the database with the exit; command.
MariaDB [sakila]> exit;
Bye
[developer@dev-dbaccess ~]$