Monday, September 21, 2015

KVM...installing...

Install and configure KVM on CentOS 6.5

1 Install KVM
yum groupinstall Virtualization 'Virtualization Client'

2 Install Libvirt
yum install libvirt
service libvirtd start

3 Make sure KVM module installed
$ lsmod | grep kvm
kvm
kvm_intel

4 Use virt-manager install Guest OS
login to GUI
1)open virt-manager,Add-connection,hypervisor choose QEMU/KVM,click connect。
2)right click localhost(QEMU) choose New.


5 Configure Bridge Network.
KVM by default use NAT, your VM can not connect to outside.
We need to create a Bridged Network Card on KVM host and then let Virtual Machine use it.

5.1 stop NetworkManager service.
# service NetworkManager stop

5.2 create ifcfg-br0
# cp /etc/sysconfig/network-scripts/ifcfg-eth0  /etc/sysconfig/network-scripts/ifcfg-br0
=================================
cat ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.14
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
=================================
cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
BRIDGE=br0
ONBOOT=yes
=================================

on KVM host
# service network restart
# brctl show


Change virtual machine settings, On NIC settings, choose your newly created br0 device

Source device ->  Host Device eth0(Bridge 'br0')
Device Model -> virtio

after this your VM should be able to talk to the outside world.
if still not, check below setting:
echo 1 > /proc/sys/net/ipv4/ip_forward

1 comment:

Linux Tables: Block All Incoming Traffic But Allow SSH

  This is very common scenario. You want to permit access to a remote machine only by SSH. You would like to block all incoming traffic to y...