I am not going to outline the installation steps required to create a kvm guest. There are plenty of tutorials available elsewhere that do that. I recommend using a Fedora 18 or greater distro as your guest as that is what I am testing this tutorial with.
4.2.1. Setup Guest Network
Run the commands below to set up a static ip address (192.168.122.10) and hostname (guest1).
export remote_hostname=guest1
export remote_ip=192.168.122.10
export remote_gateway=192.168.122.1
yum remove -y NetworkManager
rm -f /etc/hostname
cat << END >> /etc/hostname
$remote_hostname
END
hostname $remote_hostname
cat << END >> /etc/sysconfig/network
HOSTNAME=$remote_hostname
GATEWAY=$remote_gateway
END
sed -i.bak "s/.*BOOTPROTO=.*/BOOTPROTO=none/g" /etc/sysconfig/network-scripts/ifcfg-eth0
cat << END >> /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR0=$remote_ip
PREFIX0=24
GATEWAY0=$remote_gateway
DNS1=$remote_gateway
END
systemctl restart network
systemctl enable network.service
systemctl enable sshd
systemctl start sshd
echo "checking connectivity"
ping www.google.com
To simplify the tutorial we’ll go ahead and disable selinux on the guest. We’ll also need to poke a hole through the firewall on port 3121 (the default port for pacemaker_remote) so the host can contact the guest.
# setenforce 0
# sed -i.bak "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
# firewall-cmd --add-port 3121/tcp --permanent
If you still encounter connection issues just disable iptables and ipv6tables on the guest like we did on the host to guarantee you’ll be able to contact the guest from the host.
At this point you should be able to ssh into the guest from the host.