# apt-get install qemu-kvm libvirt-bin virtinst bridge-utilsGrand user to manage:
# adduser dedetok kvm---------------------------------------------------
# adduser dedetok libvirt
List all virtual
# virsh list --all---------------------------------------------------
Default KVM with NAT
---------------------------------------------------
NAT Configuring default network
# virsh net-info default---------------------------------------------------
# virsh net-autostart default
# virsh net-start default
KVM with bridge network
---------------------------------------------------
Setting up network using bridge
# brctl addbr br0---------------------------------------------------
# ip addr show
# brctl addif br0 eth0
or write configuration permanently:
---------------------------------------------------
edit /etc/network/interfaces
# The loopback network interface---------------------------------------------------
auto lo
iface lo inet loopback
# The primary network interface
#auto eth0
#iface eth0 inet static
# address 192.168.1.10
# netmask 255.255.255.0
# gateway 192.168.1.1
iface eth0 inet manual
# Initial bridge for static
auto br0
iface br0 inet static
bridge_ports eth0
address 192.168.1.10
broadcast 192.168.1.255
netmask 255.255.255.0
gateway 192.168.1.1
bridge_stp off
bridge_fd 0
bridge-waitport 0
dns-nameservers 8.8.8.8
# Initial bridge for dhcp
#auto br0
#iface br0 inet dhcp
# bridge_ports eth0
iface br0 inet6 static
address 2001:db8::1
netmask 64
gateway fe80::1
autoconf 0
#iface br0 inet6 auto
additional interface option:
- bridge_stp off # disable Spanning Tree Protocol
- bridge_waitport 0 # no delay before a port becomes available
- bridge_fd 0 # no forwarding delay
- bridge_ports none # if you do not want to bind to any ports
- bridge_ports regex eth* # use a regular expression to define ports
edit /etc/resolv.conf
nameserver 192.168.1.1---------------------------------------------------
edit /etc/sysctl.conf
net.ipv4.ip_forward = 1---------------------------------------------------
net.ipv6.conf.all.forwarding=1
For performance and security reasons, disable netfilter for bridges. Edit /etc/sysctl.conf or create /etc/sysctl.d/bridge.conf with these contents:
net.bridge.bridge-nf-call-ip6tables=0run
net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-arptables=0
# sysctl -pIf you create /etc/sysctl.d/bridge.conf, then you need to create /etc/udev/rules.d/99-bridge.rules (If using Linux kernel 3.18 or later,
change KERNEL=="bridge" to KERNEL=="br_netfilter")
ACTION=="add", SUBSYSTEM=="module", KERNEL=="bridge", RUN+="/sbin/sysctl -p /etc/sysctl.d/bridge.conf"
To allow all traffic to be forwarded across the bridge from KMV guest:
-I Insert
# /sbin/iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT-P Policy
# iptables -P INPUT ACCEPTAdd default gateway (not necessary)
# route add default gw 192.168.1.1---------------------------------------------------
network bonding and bridging
---------------------------------------------------
assuming server has 2 network interface eth0 and eth1.
# apt-get install bridge-utils ifenslaveedit /etc/network/interfaces:
# The loopback network interfaceAvailable bond mode:
auto lo
iface lo inet loopback
# The primary network interface
iface eth0 inet manual
iface eth1 inet manual
# Initial bridge for static
auto br0
iface br0 inet static
bridge_ports bond0
address 192.168.1.10
broadcast 192.168.1.255
netmask 255.255.255.0
gateway 192.168.1.1
bridge_stp off
bridge_fd 0
bridge-waitport 0
dns-nameservers 8.8.8.8
iface br0 inet6 auto
auto bond0
iface bond0 inet manual
slaves eth0 eth1
bond-mode 802.3ad
# bond_mode active-backup
bond-miimon 100
bond-downdelay 200
bond-updelay 200
- balance-rr or 0
- active-backup or 1
- balance-xor or 2
- broadcast or 3
- 802.3ad or 4
- balance-tlb or 5
- balance-alb or 6
copy iso file into folder /var/lib/libvirt/boot/ (eq dsl-4.4.10.iso)
Create virtual machine: ram 256 with Storage 5G using NAT
# virt-install --name dsl01 --ram 256 --cdrom /var/lib/libvirt/boot/dsl-4.4.10.iso --disk path=/var/lib/libvirt/images/dl01.img,size=5 --network bridge=br0 --graphics noneCreate virtual machine: ram 256 with Storage 5G using bridge
# virt-install --name dsl01 --ram 256 --cdrom /var/lib/libvirt/boot/dsl-4.4.10.iso --disk path=/var/lib/libvirt/images/dl01.img,size=5 --network bridge=br0 --graphics noneCreate virtual machine ram 2G, virtual cpu 4 with disk image bridge virbr0 (NAT) using Debian network installer no graphics (using console)
# virt-install --virt-type kvm --name deb01 --location http://httpredir.debian.org/debian/dists/jessie/main/installer-amd64/ --extra-args "console=ttyS0" -v --disk path=/home/kvmimages/deb01/disk1.img --memory 2048 --vcpu 4 --network bridge:virbr0Reference:
- http://www.cyberciti.biz/faq/debian-ubuntu-linux-kvm-guest-shared-physical-network
- http://wiki.libvirt.org/page/Networking
- https://jamielinux.com/docs/libvirt-networking-handbook/bridged-network.html
- http://www.koethe.net/bonding+bridging/
- https://ryanclouser.com/2015/11/30/Debian-8-Bonding-with-Bridge/
- https://www.kernel.org/doc/Documentation/networking/bonding.txt
- https://wiki.debian.org/KVM