Switch network via CLI

You can issue commands from the host's console to switch the VM to a different network. These are the basic steps --

  • Obtain the UUID of the XOA VM
# xe vm-list name-label="XOA"
uuid ( RO)           : 92832a7e-e72d-2d02-6a25-9802f1c24072
     name-label ( RW): XOA
    power-state ( RO): running
  • Find the VM's VIF
# xe vif-list vm-uuid=92832a7e-e72d-2d02-6a25-9802f1c24072
uuid ( RO)            : 4d321f81-c7f3-5a37-21a6-7bdb656fbc02
         vm-uuid ( RO): 92832a7e-e72d-2d02-6a25-9802f1c24072
          device ( RO): 0
    network-uuid ( RO): a379a6e7-f099-f838-6514-486de4d56e80
  • Get list of all available networks
# xe network-list
uuid ( RO)                : a379a6e7-f099-f838-6514-486de4d56e80
         name-label ( RW): Pool-wide network associated with eth0
   name-description ( RW):
             bridge ( RO): xenbr0

uuid ( RO)                : b14a0bdd-2f77-25f7-3a76-b830ff971624
         name-label ( RW): Pool-wide network associated with eth2
   name-description ( RW):
             bridge ( RO): xenbr2

uuid ( RO)                : 00b6604f-9098-023b-5880-0ef9f8e1b437
         name-label ( RW): Pool-wide network associated with eth1
   name-description ( RW):
             bridge ( RO): xenbr1

uuid ( RO)                : e3be0e1a-9872-4b90-c851-35eb30a86920
         name-label ( RW): Pool-wide network associated with eth3
   name-description ( RW):
             bridge ( RO): xenbr3

uuid ( RO)                : c54ecffe-9467-5d5f-cb73-ec10dedef2b9
         name-label ( RW): Host internal management network
   name-description ( RW): Network on which guests will be assigned a private link-local IP address which can be used to talk XenAPI
             bridge ( RO): xenapi
  • Change network associated with VIF
xe vif-move uuid=4d321f81-c7f3-5a37-21a6-7bdb656fbc02 network-uuid=b14a0bdd-2f77-25f7-3a76-b830ff971624
In the above example, the VM is originally configured to use the network associated with eth0. After running the commands, the VM is now configured to use the network associated with eth2.

If you intend to move to a bond, then you need to use `xe bond-list` instead of `xe network-list`.