Utilizzo di schede di rete multiple in Xen con Debian

From RVM Wiki
Jump to navigation Jump to search
  • Valido per Debian Squeeze

Utilizzando script Xen

  • Sul sistema HOST definire la scheda da utilizzare senza assegnare ip:
sudoedit /etc/network/interfaces 
auto eth1
iface eth1 inet manual
    hwaddress ether 00:1b:21:70:c6:e9
  • Riavviare il networking
sudo invoke-rc.d networking restart
  • Verificare che l'interfaccia sia up SENZA indirizzo IP:
ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:1b:21:70:c6:e9  
          inet6 addr: fe80::21b:21ff:fe70:c6e9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1727 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:83771 (81.8 KiB)  TX bytes:2498 (2.4 KiB)
  • Creare lo script di networking per xen:
sudoedit /etc/xen/scripts/network-bridge-wrapper
#!/bin/bash
# next two lines were good for xen-3.2.1 not for xen-4.0x anymore
#/etc/xen/scripts/network-bridge netdev=eth0 bridge=xenbr0 start
#/etc/xen/scripts/network-bridge netdev=eth1 bridge=xenbr1 start

# this works for xen-4.0x
# xen-utils-common in squeeze don't produce this script (yet) which is needed

if [ ! -f ../scripts/hotplugpath.sh ];then
        echo -e "SBINDIR=\"/usr/sbin\"
BINDIR=\"/usr/bin\"
LIBEXEC=\"/usr/lib/xen/bin\"
LIBDIR=\"/usr/lib\"
SHAREDIR=\"/usr/share\"
PRIVATE_BINDIR=\"/usr/lib/xen/bin\"
XENFIRMWAREDIR=\"/usr/lib/xen/boot\"
XEN_CONFIG_DIR=\"/etc/xen\"
XEN_SCRIPT_DIR=\"/etc/xen/scripts\"" > /etc/xen/scripts/hotplugpath.sh
        chown root:root /etc/xen/scripts/hotplugpath.sh
        chmod 755 /etc/xen/scripts/hotplugpath.sh
fi

/etc/xen/scripts/network-bridge netdev=eth0 start

# if you want to bind a NIC in domU to another interface in dom0 (bridging mode) than:
# 1.) list all dom0 interfaces you want to be able to use (except your eth0!) in "more_bridges" below
# 2.) in the domU config use: vif = [ 'mac=00:16:3e:xx:xx:xx, bridge=ethX' ] with ethX being the original device of dom0 that this domU should use
# 3.) using bridging, all interfaces in dom0 that you want to use  have to be valid configured BEFORE you run this script, i.e. before starting xend the first time.
#       (use ping -I ethX <target your gateway> to CHECK THAT BEFORE, and don't blame me if u plugged the cable into the wrong nic port ;-)
# 4.) remember, in the background xen does move the link to another name, creates a new interface etc etc... we don't care about this here, it just works fine for now

# here I want to prepare to other nics that I can choose from in the domU configs
more_bridges="eth1"

for i in $more_bridges; do
        ip addr show dev $i | egrep inet > /dev/null 2>&1
        if [ $? == 0 ];then
                ip link set $i down
                /etc/xen/scripts/network-bridge netdev=$i start
                ip link set $i up
        else
                echo -e "\nFailed to set up a bridge!\nYour device $i in dom0 seems not to be configured, so I won't try to use it as part of a bridge for any domU\n"
        fi
done
  • Aggiungere eventuali altre schede da usare separate da spazio nella riga, esempio:
more_bridges="eth1 eth2"
  • Renderlo eseguibile:
sudo chmod +x /etc/xen/scripts/network-bridge-wrapper
  • Dichiararlo nella config di xend
sudoedit /etc/xen/xend-config.sxp 
(network-script network-bridge-wrapper)
  • Riavviare xend (le vm non vengono toccate)
sudo invoke-rc.d xend restart
  • Se non da errori, vengono creati i bridge di xen:
peth1
vif2.0
  • Spegnere la VM a cui si vuole collegare la scheda:
sudo virsh shutdown mymachine
  • Aggiungere la scheda (La numerazione vif prosegue al primo decimale):
sudo virsh edit mymachine


    <interface type='bridge'>
      <mac address='00:16:36:a0:7c:d5'/>
      <source bridge='eth1'/>
      <script path='/etc/xen/scripts/vif-bridge'/>
      <target dev='vif-1.1'/>
    </interface>
  • Avviare la macchina
sudo virsh start mymachine
  • Se i bridge nell'host sono corretti, parte, altrimenti da errore.

Utilizzando bridge sull'host

TODO:

  • [Bash Adding a new NIC to Xen 4.1 - Pastebin.com]

Riferimenti