How to Configure Bridged Networking for KVM on Ubuntu 16.04 / 14.04 / Debian 9
Bridged networking or network is a dedicated network card to a virtual machine which provides a communication path to outside network, and this must be set up before creating a virtual machine using Virtual Manager.
You can either use a command line or graphical mode.
Install bridge-utils package using the apt command.
sudo apt-get install -y bridge-utils resolvconf
Edit interface file to create bridge “br1“, this should be executed on KVM host.
sudo nano /etc/network/interfaces
My machine has two network cards eth0 and eth1, so I have created a bridge using both network card.
# interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback #Bridge Name # auto br1 # Bridge Information # iface br1 inet static bridge_ports eth1 eth0 bridge_stp off bridge_fd 9 # Bride IP # address 192.168.12.7 netmask 255.255.255.0 network 192.168.12.0 broadcast 192.168.12.255 gateway 192.168.12.2 dns-nameservers 192.168.12.2 dns-nameservers 126.96.36.199
Bring up the bridge.
sudo ifup br1
Restart the network service.
sudo service networking restart
Click on the dash and search for Virtual Machine Manager.
Edit >> Connection details >> Click on Plus sign.
Choose bridge as an interface type and then click on forward.
Set a Name, start mode as on boot and choose to activate now.
You can configure ip address by clicking on Configure right to IP settings. Once IP is configured, click OK.
Clik on the finish to create a bridge called “br1”.
Verify ip address by using the following command.
br1 Link encap:Ethernet HWaddr 00:0c:29:26:55:17 inet addr:192.168.12.7 Bcast:192.168.12.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe26:5517/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:250 errors:0 dropped:0 overruns:0 frame:0 TX packets:229 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:21236 (21.2 KB) TX bytes:31676 (31.6 KB)