Friday, January 15, 2016

Debian Jessie KVM

Installasi:
# apt-get install qemu-kvm libvirt-bin virtinst bridge-utils
Grand 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=0
net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-arptables=0
run
# sysctl -p
If 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 ACCEPT
Add 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 ifenslave
edit /etc/network/interfaces:
# The loopback network interface
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
Available bond mode:
  • 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 none
Create 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 none
Create 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:virbr0
Reference:

No comments:

Post a Comment