Resetting Network Interface Rules
To properly configure network interfaces for cloned virtual machines, you'll need to clear and regenerate the udev persistent network rules:
# Clear existing network rules
# rm -f /etc/udev/rules.d/70-persistent-net.rules
# Reload network module
# rmmod e1000 && modprobe e1000
KVM Virtualization Installation
First verify you're processor supports hardware virtualization extensions:
# Check CPU virtualization support
# grep -E "(svm|vmx)" /proc/cpuinfo
# Install required packages
# yum install -y qemu-kvm qemu-img virt-install libvirt python3-libvirt virt-manager
# Verify KVM module is loaded
# lsmod | grep kvm
Component Overview:
- kvm: Kernel module providing virtualization infrastructure
- qemu: Emulation layer for hardware virtualization
- qemu-kvm: Userspace component managing KVM resources
Virtual Network Configuraton
Method 1: Command Line Configuration
# Define and start custom networks
# virsh net-edit isolated-network
# virsh net-autostart isolated-network
# virsh net-start isolated-network
# Configure additional networks
# virsh net-autostart dmz-network
# virsh net-start dmz-network
# virsh net-list --all
Method 2: Graphical Configuration
# Install GUI dependencies
# yum install -y xorg-x11-xauth xorg-x11-fonts dejavu-sans-fonts
# Copy network definitions
# cp /custom/networks/isolated*.xml /etc/libvirt/qemu/networks/
# Launch virtualization manager
# virt-manager
VM Template Preparation
# Deploy base template and configuration
# cp /templates/rhel-base.img /var/lib/libvirt/images/
# cp /templates/rhel-base.xml /var/lib/libvirt/images/
# Create cloning utility
# cp /scripts/deploy-vm /usr/local/bin/deploy-vm
# chmod +x /usr/local/bin/deploy-vm
Essential KVM Management Commands
# List all virtual machines
# virsh list --all
# Power management operations
# virsh start webserver01
# virsh shutdown webserver01
# virsh destroy webserver01 # Force power off
# virsh reboot webserver01
# Remove VM configuration
# virsh undefine webserver01
# rm -f /var/lib/libvirt/images/webserver01.img
# Console access
# virsh console webserver01
File Locations:
- Configuration:
/etc/libvirt/qemu/[vmname].xml - Disk images:
/var/lib/libvirt/images/[vmname].img
Network Address Translation Setup
# Disable conflicting services
# setenforce 0
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl stop NetworkManager
# systemctl disable NetworkManager
# Configure NAT rules
# iptables -F
# iptables -t nat -F
# iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j SNAT --to-source 203.0.113.45
# Enable IP forwarding
# sysctl -w net.ipv4.ip_forward=1
# echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
System Administration Tools
- tcpdump: Network packet analysis and troubleshooting
- strace: System call tracing for debugging processes
- tmux: Terminal multiplexer for persistent sessions
- taskset: CPU affinity management for process binding
Vim Batch Operations
Multi-line commenting:
- Press Ctrl+v to enter visual block mode
- Select target lines using arrow keys
- Press Shift+i and type comment character
- Press Esc to apply to all selected lines
Removing comments:
- Press Ctrl+v and select comment columns
- Press d to delete selected content
Additional Storage Configuration
Create and mount secondary storage for VM images:
# Partition new disk
# fdisk /dev/vdb
# n (new partition)
# p (primary)
# 1 (partition number)
# [accept defaults]
# w (write changes)
# Format and mount
# mkfs.xfs /dev/vdb1
# mount /dev/vdb1 /var/lib/libvirt/images
# Persist mount across reboots
# echo '/dev/vdb1 /var/lib/libvirt/images xfs defaults 0 0' >> /etc/fstab