Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hmidani-abdelilah/bed7e71cb4e911d88f195c46cac24672 to your computer and use it in GitHub Desktop.
Save hmidani-abdelilah/bed7e71cb4e911d88f195c46cac24672 to your computer and use it in GitHub Desktop.
KVM3: Configuring the system
# In The Name Of Allah .
# -- --- ---- -- ----- -
# Sun Nov 8 07:42:54 2020
# Written By : zer0err0r .
# ======= == = ========= =
# 3, Configuring The System .
# Adding our user to [libvirt] group :
$ usermod -aG libvirt zer0err0r
# Relogin or start a new bash session, Or execute :
$ newgrp libvirt
# Set system_DBus aliases instead of session_DBus :
$ vim ~/.bashrc
alias virsh="virsh --connect 'qemu:///system'"
alias virt-install="virt-install --connect 'qemu:///system'"
alias virt-top="virt-top --connect 'qemu:///system'"
alias virt-clone="virt-clone --connect 'qemu:///system'"
alias virt-manager="virt-manager --connect 'qemu:///system'"
alias virt-viewer="virt-viewer --connect 'qemu:///system'"
$ source ~/.bashrc
# For remote :
$ vim ~/.bashrc
alias virsh="virsh --connect 'qemu+ssh://user@ip/system'"
= Then set a passwordless authentication with the remote hypervisor host .
- Just use [ssh-keygen, ssh-copy-id] commands .
# Set a bridged connection :
= Attention, Use an ethernet cable .
= Most wifi cards will get you into the promiscous_mode issue .
$ sudo -i
$ echo 'BRIDGE=br0' >> /etc/sysconfig/network-scripts/ifcfg-ens3
$ vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
BOOTPROTO=static
IPADDR=192.168.100.102
NETMASK=255.255.255.0
NETWORK=192.168.100.0
GATEWAY=192.168.100.1
DNS1=8.8.8.8
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
ONBOOT="yes"
TYPE="Bridge"
DELAY="0"
$ sudo systemctl restart NetworkManager
= From now on, We should not configure [ens3] at all, We configure [br0] instead .
= [br0] is the master now while [ens3] is a member[slave] of it .
# [nmcli] method :
= I need to test it first before recording it .
= I will explain it later ISA .
# Enable port forwarding :
$ echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
$ sysctl -p /etc/sysctl.conf
# ===== == ==== ======== =
# Peace Be Up0n Muhammed .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment