Configurar a rede de pontes:
Edit /etc/network/interfaces
# vi /etc/network/interfaces
...
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address [ipv4]
netmask [netmask]
network [network]
broadcast [broadcast]
gateway [ipv4gateway]
bridge_ports eth0
bridge_stp on
bridge_maxwait 0
iface br0 inet6 static
address [ipv6]
netmask 64
dns-nameservers [dnsipv6]
gateway [ipv6gatewaay]
autoconf 0
# internal
auto virbr0
iface virbr0 inet static
address 192.168.0.1
netmask 255.255.255.0
broadcast 192.168.0.255
pre-up brctl addbr virbr0
edite o /etc/sysctl.conf.d
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding=1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
Manual adicionando virbr0
# brctl addbr virbr0
# ifconfig virbr0 192.168.0.1 netmask 255.255.255.0 up
Instale e configure o servidor dhcp para domu Instale o isc-dhcp-server
# apt-get install isc-dhcp-server
Edite / etc / default / isc-dhcp-server
INTERFACES="virbr0"
Edit /etc/dhcp/dhcpd.conf
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.50;
option routers 192.168.0.1;
default-lease-time 600;
max-lease-time 7200;
}
Reinicie o servidor dhcp
# service isc-dhcp-server restart
Configurando a ferramenta xen para criar imagens domu edite o /etc/xen-tools/xen-tools.conf
#Begin by setting the dir = directive to the directory into which the tools are to create the Xen guest image files:
dir = /home/images
#lvm = myvolgroup -> if using LVM (logical volume management)
install-method = debootstrap
debootstrap-cmd = /usr/sbin/debootstrap
size = 4G # Root disk, suffix (G, M, k) required
memory = 512M # Suffix (G, M, k) required
swap = 1G # Suffix (G, M, k) required
fs = ext3 # Default file system for any disk
dist = 'jessie' # Default distribution is determined by Dom0's distribution
image = sparse # Specify sparse vs. full disk images (file based images only)
# for static
# gateway = 192.168.1.1
# netmask = 255.255.255.0
# broadcast = 192.168.1.255
dhcp=1
bridge = virbr0
genpass_len = 8
passwd = 1
kernel = /boot/vmlinuz-'uname -r'
initrd = /boot/initrd.img-'uname -r'
pygrub = 1
mirror = http://debian.mirrors.ovh.net/debian
mirror_jessie = http://http.debian.net/debian
ext4_options = noatime,nodiratime,errors=remount-ro
ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiserfs_options = defaults
btrfs_options = defaults
output = /etc/xen
extension = .cfg
Criando imagem de disco Xen (imagem de loopback) para o convidado Xen Crie um convidado xen com nome de host testa, disco 10G, swap 1G, RAM / memória 512M, dhcp, vcpu 3, OS Debiean jessie:
# xen-create-image --hostname testa --size=10Gb --swap=1024Mb --memory=512Mb --vcpu=3 --dist=jessie
Can't exec "jessie": No such file or directory at /usr/share/perl5/Xen/Tools/Common.pm line 100, <FILE> line 134.
Use of uninitialized value $output in scalar chomp at /usr/share/perl5/Xen/Tools/Common.pm line 101, <FILE> line 134.
Use of uninitialized value $output in concatenation (.) or string at /usr/share/perl5/Xen/Tools/Common.pm line 104, <FILE> line 134.
General Information
--------------------
Hostname : testa
Distribution : jessie
Mirror : http://debian.mirrors.ovh.net/debian
Partitions : swap 1024Mb (swap)
/ 10Gb (ext3)
Image type : sparse
Memory size : 512Mb
Bootloader : pygrub
Networking Information
----------------------
IP Address : DHCP [MAC: 00:16:3E:73:6F:31]
Creating partition image: /home/vmimages/domains/testa/swap.img
Done
Creating swap on /home/vmimages/domains/testa/swap.img
Done
Creating partition image: /home/vmimages/domains/testa/disk.img
Done
Creating ext3 filesystem on /home/vmimages/domains/testa/disk.img
Done
Installation method: debootstrap
Done
Running hooks
Done
No role scripts were specified. Skipping
Creating Xen configuration file
Done
No role scripts were specified. Skipping
Setting up root password
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
All done
Logfile produced at:
/var/log/xen-tools/testa.log
Installation Summary
---------------------
Hostname : testa
Distribution : jessie
MAC Address : 00:16:3E:73:6F:31
IP Address(es) : dynamic
RSA Fingerprint : 21:12:bb:c3:ad:34:67:6f:cd:a1:7d:d3:ef:ae:95:f5
Root Password : N/A
Esse processo leva aproximadamente 14 minutos. Executar convidado xen Para executar o xen guest
# xl create /etc/xen/testa.cfg -c
Roteamento Interno para internet
# iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -A FORWARD -i virbr0 -o br0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# iptables -A FORWARD -i virbr0 -o br0 -j ACCEPT
Internet to internal in port xxx into 192.168.0.100 port yyy
# iptables -A PREROUTING -t nat -i br0 -p tcp --dport xxx -j DNAT --to 192.168.0.100:yyy
# iptables -A FORWARD -p tcp -d 192.168.0.100 --dport yyy -j ACCEPT
Faça auto-start domu após o boot Crie um symlink na pasta / etc / xen / auto
# mkdir /etc/xen/auto
# cd /etc/xen/auto/
# ln -s /etc/xen/testa.cfg
edite o arquivo /etc/xen/testa.cfg
# vi /etc/xen/testa.cfg
on_xend_stop='shutdown'
on_xend_start='start'
para instruções completas, leia: link