User Tools

Site Tools


Sidebar

kvm:bridge_interface

This is an old revision of the document!


KVM bridged networking

By default dhcpd based network bridge configured by libvirtd. You can verify that with the following commands:

# brctl show
# virsh net-list

KVM default networking All VMs (guest machine) only have network access to other VMs on the same server. A private network 192.168.122.0/24 created for you. Verify it:

# virsh net-dumpxml default

If you want your VMs avilable to other servers on your LAN, setup a a network bridge on the server that connected to the your LAN.

Bridge with NetworkManager and DHCP

Update your nic config file such as ifcfg-enp3s0 or em1: # vi /etc/sysconfig/network-scripts/enp3s0

Add line:

BRIDGE=br0

Save and close the file in vi. Edit /etc/sysconfig/network-scripts/ifcfg-br0 and add:

# vi /etc/sysconfig/network-scripts/ifcfg-br0

Append the following:

DEVICE="br0"
# I am getting ip from DHCP server #
BOOTPROTO="dhcp"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
ONBOOT="yes"
TYPE="Bridge"
DELAY="0"

Restart the networking service (warning ssh command will disconnect, it is better to reboot the box):

# systemctl restart NetworkManager

Verify it with brctl command:

# brctl show

Manual Bridge with static IP

By KVM Virtual Manager can be created bridge interface on each of network interface

If you have two LAN interface with two VLAN network

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE="br1"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="none"
IPADDR="10.5.22.51"
NETMASK="255.255.255.0"
GATEWAY="10.5.22.254"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
DHCPV6C="no"
STP="on"
DELAY="0.0"
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br2
DEVICE="br2"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="none"
IPADDR="10.5.23.10"
NETMASK="255.255.255.0"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
DHCPV6C="no"
STP="on"
DELAY="0.0"
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BRIDGE="br1"
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BRIDGE="br2"
If you want to after reboot or restart network service save bridge configuration
[root@localhost ~]# cat /sbin/ifup-local
#!/bin/sh
 
ip route add default via 10.5.23.254 dev br2 table rt2;
ip rule add from 10.5.23.0/24 table rt2
kvm/bridge_interface.1617956601.txt.gz · Last modified: 2021/04/09 10:23 by admin