Create a new network config with no gateway addresses on KVM ("very private" or "very isolated")
This type of network can be used for a very private or very isolated network since it will not be possible to communicate with the virtualization host via this network. However, this virtual network interface can be used for communication between virtual guest systems. This works for IPv4 and IPv6. However, the new ipv6='yes' must be added for guest-to-guest IPv6 communication.
- Check networks status in KVM and OS
Check networks in use by KVM...
brctl show
Check KVM Virtual Networks...
virsh net-list
Check networks in OS...
ip a
- Create a new network config with no gateway addresses
MODEL
read -r -d '' FILE_CONTENT << 'HEREDOC'
BEGIN
<network>
<name>[MY_NETWORK_NAME]</name>
<uuid>[MY_NETWORK_UUID]</uuid>
<bridge name='virbr[MY_NETWORK_NUMBER]' stp='on' delay='0'/>
<mac address='52:54:00:[MY_NETWORK_MAC_FINAL]'/>
</network>
END
HEREDOC
echo -n "${FILE_CONTENT:6:-3}" > '/usr/share/libvirt/networks/[MY_NETWORK_NAME].xml'
- "[MY_NETWORK_NAME]" - Name in lowercase without spaces and special characters;
- "[MY_NETWORK_UUID]" ("uuid" is OPTIONAL) - You can generate a new one at the URL https://www.uuidgenerator.net/version4 ;
- "[MY_NETWORK_NUMBER]" - We use the "virbr" prefix to follow the existing naming "convention";
- "[MY_NETWORK_MAC_FINAL]" ("mac" is OPTIONAL) - The prefix "52:54:00:" is always the same, otherwise the error "Invalid multicast bridge mac address" will happen. You can generate a new one at the URL https://miniwebtool.com/mac-address-generator/ .
EXAMPLE
read -r -d '' FILE_CONTENT << 'HEREDOC'
BEGIN
<network>
<name>okd_very_private</name>
<uuid>cbc4be8a-1fc5-4e1a-8065-e12dab7d4175</uuid>
<bridge name='virbr1' stp='on' delay='0'/>
<mac address='52:54:00:CB:8A:F0'/>
</network>
END
HEREDOC
echo -n "${FILE_CONTENT:6:-3}" > '/usr/share/libvirt/networks/okd_very_private.xml'
Add the new network definition XML file to libvirt...
MODEL
virsh net-define "/usr/share/libvirt/networks/[MY_NETWORK_NAME].xml"
EXAMPLE
virsh net-define "/usr/share/libvirt/networks/okd_very_private.xml"
NOTE: The "net-define" is an alternative to "net-create". Use this when you want a persistent virtual network that will last through reboots and shutdowns, rather than a transient one created using "net-create".
Start the new network...
MODEL
virsh net-start [MY_NETWORK_NAME]
EXAMPLE
virsh net-start okd_very_private
To set the new network to automatically startup each time the KVM host is rebooted...
MODEL
virsh net-autostart [MY_NETWORK_NAME]
EXAMPLE
virsh net-autostart okd_very_private
TIP: To view configuration details of a specific network defined in libvirt, use the command...
MODEL
virsh net-dumpxml [MY_NETWORK_NAME]
EXAMPLE
virsh net-dumpxml okd_very_private
.
[Ref(s).: https://libvirt.org/formatnetwork.html#examplesNoGateway ]
Especial thanks to @berndbausch ! =D