Hello, and welcome to today's video presentation on switching a KVM VM from NAT-based to Bridge-based
networking on Oracle Linux 8.
This video will edit an existing NAT-based virtual machine to use a network bridge using
both the command line and the Cockpit web console.
So let us get started.
For this demo, I use a physical Oracle Linux 8 system pre-configured with the KVM virtualization
packages, and an Oracle Linux 8.2 guest VM associated with the default KVM NAT network.
Beyond the default NAT virtual network (virbr0), the system is pre-configured with a bridged
network (br0).
Additional details on configuring those items are available in our other Linux and KVM videos
linked in the description and at the end of this video.
The steps in this video apply to physical, and on-premise systems and not intended for
Oracle Cloud Infrastructure.
In this example, use the pre-existing ol8-test virtual machine that has a NAT-based network
by default.
Using the terminal, type sudo virsh list --all.
This command checks the State of the ol8-test VM.
Next, get the list of virtual interfaces by typing the command sudo virsh domiflist ol8-test.
The command shows the NAT-based virtual network listed as interface vnet0.
Before removing this interface, stop the VM by typing sudo virsh shutdown ol8-test.
Once the VM is shut-off, remove the vnet0 interface by typing the command on the screen.
[ silence while typing sudo virsh detach-interface --domain ol8-test --type network --mac 52:54:00:95:4b:a3
--config ]
Note that your MAC address assigned to this interface will vary based on your environment.
The command returns successfully.
Attach the new network bridge by typing the command on the screen.
[ silence while typing sudo virsh attach-interface --domain ol8-test --type bridge --source br0
--model virtio --config ]
The command returns successfully.
Verify the configuration changes took effect by viewing the VM config.
Type sudo virsh edit ol8-test to view the config.
The command opens the configuration in the system default editor, vi, in this environment.
Search the file for the interface section.
With the changes now showing the network bridge (br0), quit and close the configuration.
Now start the VM by typing sudo virsh start ol8-test.
Wait for the VM to start.
Show the VM network list by typing sudo virsh domiflist ol8-test.
The vnet0 interface displays the type as a bridge with a source as br0.
Check that network assigned a proper DHCP address by typing sudo virsh domifaddr ol8-test
--source agent.
Seeing the proper ip_addres confirms the configuration of the VM for the bridged network.
Now that the VM was modified using the command-line, the same is possible using the Cockpit web
console.
After reversing all the steps done using the command line, open the browser and access
the Cockpit web console.
Navigate to Virtual Machines and expand ol8-test by clicking the arrow next to its name.
Stop the VM by clicking the Shut Down button on the right.
Navigate from the Consoles tab to the Network Interfaces tab.
Click the Delete button to the right of the network interface where Source equals default.
Click the Delete button in the Delete Network Interface confirmation panel.
Next, click the Add Network Interface button on the right.
In the Add Virtual Network Interface panel, select Bridge to LAN for Interface Type.
For the Source, select br0.
Keep the model as virtio and MAC Address as Generate automatically.
Click the Add button at the bottom.
That completes the network interface change.
Start the VM by clicking the Run button to the right.
Navigate from the Network Interfaces tab back to the Consoles tab.
Once the system is running, log in with your system credentials.
In the console, type the command ip add.
Check the VM ethernet inet address and confirm it received an ip_address from the network
bridge DHCP server.
That completes our demo of switching a KVM VM from a NAT-based network to a bridged-based
network using the command-line and the Cockpit web console.
Thank you for watching this video and enjoy using KVM on Oracle Linux 8.
Please check our additional information on Oracle Linux 8 in the Oracle Linux 8 Documentation
or Oracle Linux Learning Library.