Networking: PIF VIF
Networking: PIF VIF
Table of Contents Networking configuration performed during Host installation Managing networking configuration for standalone XenServer Hosts Creating networks Connecting Virtual Machines (VMs) to networks Creating VLANs Creating NIC bonds Controlling Quality of Service (QoS) Dedicating a NIC to storage traffic Changing networking configuration options Managing networking configuration for XenServer pools Networks in resource pools Creating NIC bonds in resource pools Changing XenServer Host IP address configuration in resource pools NIC/PIF ordering Networking Troubleshooting Diagnosing network corruption Recovering from a bad network configuration This chapter discusses how physical network interface cards (NICs) in XenServer Hosts are used to enable networking within Virtual Machines (VMs). XenServer supports up to 4 physical NICs per XenServer Host and up to 7 virtual network interfaces (VIFs) per VM. XenServer 4.1 provides automated configuration and management of NICs via the xe command line interface (CLI). As VIFs, PIFs, and networks are created and configured the XenServer Host will perform all required configuration of the physical NICs.
Note
Unlike previous XenServer versions, the host's networking configuration files should not be edited directly in most cases; where a CLI command is available, do not edit the underlying files. Some networking options have different behaviors when used with standalone XenServer Hosts compared to resource pools. This chapter contains sections on general information that applies to both standalone hosts and pools, and additional information that applies when using pools. The xe CLI can be used to create, destroy and modify three types of server-side objects which represent networking entities. These objects are:
A PIF, which represents a physical network interface on a XenServer Host. A VIF, which represents a virtual interface on a Virtual Machine.
A network, which is a virtual Ethernet switch on a XenServer Host. Network objects have a name and description, a globally unique UUID, and the collection of VIFs and PIFs connected to the network.
Additional CLI commands allow configuration of networking options, control over which NIC is used for management operations, and creation of advanced networking features such as virtual local area networks (VLANs) and NIC bonds. The examples in this chapter assume familiarity with the xe CLI. For more information on using the xe CLI, see Command line interface.
a single PIF is created corresponding to the host's single NIC the PIF is configured with the IP addressing options specified during installation and to enable management of the host the PIF is set for use in host management operations a single network, network 0, is created network 0 is connected to the PIF to enable external connectivity to VMs
When a host has multiple NICs the configuration present after installation depends on which NIC is selected for management operations during installation:
PIFs are created for each NIC in the host the PIF of the NIC selected for use as the management interface is configured with the IP addressing options specified during installation a network is created for each PIF ("network 0", "network 1", etc.) each network is connected to one PIF the IP addressing options of all other PIFs are left unconfigured
In both cases the resulting networking configuration allows connection to the XenServer Host by XenCenter, the xe CLI, and any other management software running on separate machines via the IP address of the management interface. The configuration also provides external networking for VMs created on the host. The PIF used for management operations is the only PIF ever configured with an IP address. External networking for VMs is achieved by bridging PIFs to VIFs via the network object which acts as a virtual Ethernet switch. The steps required for networking features such as VLANs, NIC bonds, and dedicating a NIC to storage traffic are covered in the following sections.
external,
and provide a bridge between VIFs and the PIF connected to the network, enabling connectivity to resources
use an internal network support advanced operations such as VLANs or NIC bonding
To add or remove networks using XenCenter, refer to the XenCenter online Help. To add a new network via the CLI 1. 2. Open the XenServer Host text console. Create the network with the network-create command, which returns the UUID of the newly created network:
3. xe network-create name-label=<mynetwork>
At this point the network is not connected to a PIF and therefore is internal.
3.
Add a VIF to the VM with the vif-create command, specifying the VM and network UUIDs. The UUID of the new virtual interface will be returned:
The device parameter is a number which uniquely identifies the virtual NIC (0, 1, 2, etc.) to a VM. 5. VIFs are automatically plugged into VMs when a VM is started, but if the VM is already running when the VIF is created, the VIF must be manually connected, or hot-plugged. Hot-plugging VIFs requires the
XenServer Virtual Machine Installation Guide for details on installing the XenServer Tools. To hot-plug a VIF to a VM use the
XenServer Tools to be installed in the VM. Refer to the vif-plug command:
Creating VLANs
Virtual Local Area Networks (VLANs) allow a single physical network to support multiple logical networks. To use VLANs with XenServer, the host's NIC must be connected to a VLAN trunk port. XenServer VLANs are represented by additional PIFs corresponding to a specified VLAN tag. XenServer networks can then be connected to the PIF representing the physical NIC to see all traffic on the NIC, or to a PIF representing a VLAN to see only the traffic with the specified VLAN tag. When using VLANs the XenServer Host handles all interpretation of the VLAN tags and does not include VLAN tags in packets routed to VMs. To connect a network to an external VLAN via the CLI 1. 2. Open the XenServer Host text console. Create a new network for use with the VLAN. The UUID of the new network is returned:
3. xe network-create name-label=network5
4.
Use the pif-list command to find the UUID of the PIF corresponding to the physical NIC supporting the desired VLAN tag. The UUIDs and device names of all PIFs are returned, including any existing VLANs:
5. xe pif-list
6.
Create a VLAN object specifying the desired physical PIF and VLAN tag. A new PIF will be created and plugged into the specified network. The UUID of the new PIF object is returned.
8.
Attach VM VIFs to the new network. See the section called Connecting Virtual Machines (VMs) to networks for more details.
NIC bonds can improve XenServer Host resiliency by using two physical NICs as if they were one. If one NIC within the bond fails the host's network traffic will automatically be routed over the second NIC. NIC bonds work in an active/passive mode, with only one physical NIC ever in use. XenServer NIC bonds completely subsume the underlying physical devices (PIFs). In order to activate a bond the underlying PIFs must not be in use, either as the management interface for the host or by running VMs with VIFs attached to the networks associated with the PIFs. XenServer NIC bonds are represented by additional PIFs. The bond PIF can then be connected to a XenServer network to allow VM traffic and host management functions to occur over the bonded NIC. The exact steps to use to create a NIC bond depend on the number of NICs in your host, and whether the management interface of the host is assigned to a PIF to be used in the bond. Also see the section called Creating NIC bonds in resource pools for details on creating NIC bonds with resource pools. Creating a NIC bond on a dual-NIC host Creating a bond on a dual-NIC host implies that the PIF/NIC currently in use as the management interface for the host will be subsumed by the bond. The additional steps required to move the management interface to the bond PIF are included. To create a NIC bond a dual-NIC host 1. Use XenCenter or the vm-shutdown command to shut down all VMs on the host, thereby forcing all VIFs to be unplugged from their current networks. The existing VIFs will be invalid after the bond is enabled.
3.
Use the network-create command to create a new network for use with the bonded NIC. The UUID of the new network is returned:
4. xe network-create name-label=bond0
5.
Use the pif-list command to determine the UUIDs of the PIFs to use in the bond:
6. xe pif-list 7.
8.
Use the bond-create command to create the bond by specifying the newly created network UUID and the UUIDs of the PIFs to be bonded separated by commas. The UUID for the bond is returned:
Note
See the section called Controlling the MAC address of the bond for details on controlling the MAC address used for the bond PIF. 10. Use the pif-list command to determine the UUID of the new bond PIF:
11.
xe pif-list device=bond0
12. Use the pif-reconfigure-ip command to configure the desired management interface IP address settings for the bond PIF. See Command line interface for more detail on the options available for the pifreconfigure-ip command.
13.
14. Use the host-management-reconfigure command to move the management interface from the existing physical PIF to the bond PIF. This step will activate the bond:
15.
16. Use the pif-reconfigure-ip command to remove the IP address configuration from the non-bonded PIF previously used for the management interface. This step is not strictly necessary but might help reduce confusion when reviewing the host networking configuration.
17.
18. Move existing VMs to the bond network using the vif-destroy and vif-create commands. This step can also be completed via XenCenter by editing the VM configuration and connecting the existing VIFs of a VM to the bond network. 19. Restart the VMs shut down in step 1. Controlling the MAC address of the bond Creating a bond on a dual-NIC host implies that the PIF/NIC currently in use as the management interface for the host will be subsumed by the bond. If DHCP is used to supply IP addresses to the host in most cases the MAC address of the bond should be the same as the PIF/NIC currently in use, allowing the IP address of the host received from DHCP to remain unchanged. The MAC address of the bond can be changed from PIF/NIC currently in use for the management interface, but doing so will cause existing network sessions to the host to be dropped when the bond is enabled and the MAC/IP address in use changes. The MAC address to be used for a bond can be controlled in two ways:
an optional mac parameter can be specified in the bond-create command. Using this parameter, the the bond MAC address can be set to any arbitrary address. If the mac parameter is not specified, the MAC address of the first PIF listed in the pif-uuids parameter is used for the bond.
Reverting NIC bonds If reverting a XenServer Host to a non-bonded configuration, be aware of the following requirements:
As when creating a bond, all VMs with VIFs on the bond must be shut down prior to destroying the bond. After reverting to a non-bonded configuration, reconnect the VIFs to an appropriate network. Move the management interface to another PIF using the pif-ip-reconfigure and hostmanagement-reconfigure commands prior to issuing the bond-destroy command, otherwise connections to the host (including XenCenter) will be dropped.
Note
Use of the pif-scan command will reset all NICs on the host to managed.
The system host-name is defined in the pool-wide database and modified using the xe host-set-hostnamelive CLI command as follows:
XenServer Host IP address configuration Network interface configuration can be manipulated via the xe command-line interface (CLI). Unlike earlier XenServer versions, the underlying network configuration scripts should not be modified directly without using the CLI. To modify the IP address configuration of a PIF, use the pif-reconfigure-ip CLI command. See the section called pifreconfigure-ip for details on the parameters of the pif-reconfigure-ip command.
Note
See the section called Changing XenServer Host IP address configuration in resource pools for details on changing host IP addresses in resource pools. Management interface When XenServer is installed on a host with multiple NICs, one NIC is selected for use as the management interface. The management interface is used for XenCenter connections to the host and for host-to-host communication. To change the NIC used for the management interface 1. Use the pif-list command to determine which PIF corresponds to the NIC desired for use as the management interface. The UUID of each PIF will be returned.
2. xe pif-list
3.
Use the pif-param-list command to verify the IP addressing configuration for the PIF that will be used for the management interface. If necessary, use the pif-reconfigure-ip command to configure IP addressing for the PIF to be used. See Command line interface for more detail on the options available for the pif-reconfigure-ip command.
5.
Use the host-management-reconfigure CLI command to change the PIF used for the management interface:
Disabling management access To disable remote access to the management console entirely, use the host-management-disable CLI command. But be careful! Once the management interface is disabled, you will have to log in on the physical host console to perform management tasks and external interfaces such as XenCenter will no longer work.
3. Use the host-list command to find the UUID of the master host:
4. xe host-list
5. Use the pif-list command to determine the UUIDs of the PIFs to use in the bond:
6. 7. xe pif-list
8. Use the bond-create command to create the bond, specifying the network UUID created in step 1 and the UUIDs of the PIFs to be bonded, separated by commas. The UUID for the bond is returned:
9. 10.
Note
See the section called Controlling the MAC address of the bond for details on controlling the MAC address used for the bond PIF. 11. Use the pif-list command to determine the UUID of the new bond PIF:
12. 13.
14. Use the pif-reconfigure-ip command to configure the desired management interface IP address settings for the bond PIF. See Command line interface for more detail on the options available for the pif-reconfigure-ip command.
15. 16.
17. Use the host-management-reconfigure command to move the management interface from the existing physical PIF to the bond PIF. This step will activate the bond:
18. 19.
20. Use the pif-reconfigure-ip command to remove the IP address configuration from the nonbonded PIF previously used for the management interface. This step is not strictly necessary but might help reduce confusion when reviewing the host networking configuration.
21. 22.
3. 4.
Join a member server to the pool.The network and bond information will be automatically replicated to the member server. Move the management interface on the member server to enable the bond as follows: 1. Use the host-list command to find the UUID of the member host being configured:
2. xe host-list
3. Use the pif-list command to determine the UUID of bond PIF on the new member host. Include the host-uuid parameter to list only the PIFs on the host being configured:
5. Use the pif-reconfigure-ip command to configure the desired management interface IP address settings for the bond PIF with the pif-reconfigure-ip command. See Command line interface for more detail on the options available for the pif-reconfigure-ip command. This command must be run directly on the member server to be affected:
7. Use the host-management-reconfigure command to move the management interface from the existing physical PIF to the bond PIF. This step will activate the bond. This command must be run directly on the member server to be affected:
9. Use the pif-reconfigure-ip command to remove the IP address configuration from the nonbonded PIF previously used for the management interface. This step is not strictly necessary but may help reduce confusion when reviewing the host networking configuration. This command must be run directly on the member server to be affected:
10.
5.
For each member server, join it to the pool and repeat 3 and 4 to move the management interface on the member server to enable the bond.
Adding NIC bonds to an existing pool When adding a NIC bond to an existing pool, the bond must be manually created on each host in the pool. The steps below can be used to add NIC bonds on both the pool master and member servers with the following requirements: 1. 2. 3. All VMs in the pool must be shut down Add the bond to the pool master first, and then to member hosts. The bond-create, host-management-reconfigure and host-management-disable commands affect the host on which they are run and so are not suitable for use on one host in a pool to change the configuration of another. Run these commands directly on the console of the host to be affected.
To add NIC bonds to existing pool master and member hosts 1. Use the network-create command to create a new pool-wide network for use with the bonded NICs. This step should only be performed once per pool. The UUID of the new network is returned.
2. xe network-create name-label=bond0
3.
Use XenCenter or the vm-shutdown command to shut down all VMs in the host pool to force all existing VIFs to be unplugged from their current networks. The existing VIFs will be invalid after the bond is enabled.
5.
Use the host-list command to find the UUID of the host being configured:
6. xe host-list
7.
Use the pif-list command to determine the UUIDs of the PIFs to use in the bond. Include the hostuuid parameter to list only the PIFs on the host being configured:
9.
Use the bond-create command to create the bond, specifying the network UUID created in step 1 and the UUIDs of the PIFs to be bonded, separated by commas. The UUID for the bond is returned.
10.
Note
See the section called Controlling the MAC address of the bond for details on controlling the MAC address used for the bond PIF. 11. Use the pif-list command to determine the UUID of the new bond PIF. Include the host-uuid parameter to list only the PIFs on the host being configured:
12.
13. Use the pif-reconfigure-ip command to configure the desired management interface IP address settings for the bond PIF. See Command line interface for more detail on the options available for the pif-reconfigure-ip command. This command must be run directly on the server to be affected:
14.
15. Use the host-management-reconfigure command to move the management interface from the existing physical PIF to the bond PIF. This step will activate the bond. This command must be run directly on the member server to be affected:
16.
17. Use the pif-reconfigure-ip command to remove the IP address configuration from the nonbonded PIF previously used for the management interface. This step is not strictly necessary, but might help reduce confusion when reviewing the host networking configuration. This command must be run directly on the member server to be affected:
18.
19. Move existing VMs to the bond network using the vif-destroy and vif-create commands. This step can also be completed via XenCenter by editing the VM configuration and connecting the existing VIFs of the VM to the bond network. 20. Repeat steps 3 - 10 for member servers. 21. Restart the VMs previously shut down.
3.
Use the host-list CLI command to confirm that the member host has successfully reconnected to the master host by checking that all the other XenServer Hosts in the pool are visible:
4. xe host-list
Changing the IP address of the master XenServer Host requires additional steps because each of the member hosts uses the master's advertised IP address for communication and will not know how to contact the master when its IP address changes. Whenever possible, use a dedicated IP address that is not likely to change for the lifetime of the pool for pool masters. To change the IP address of a pool master host 1. Use the pif-reconfigure-ip CLI command to set the IP address as desired. See Command line interface for details on the parameters of the pif-reconfigure-ip command:
3. 4.
When the IP address of the pool master host is changed, all member hosts will enter into an emergency mode when they fail to contact the master host. On the master XenServer Host, use the pool-recover-slaves command to force the master to contact each of the member servers and inform them of the master's new IP address:
5. xe pool-recover-slaves
Refer to the the section called Master failures for more information on emergency mode.
NIC/PIF ordering
It is possible for physical NIC devices to be discovered in different orders on different servers even though the servers contain the same hardware. Verifying NIC ordering is recommended before using the pooling features of XenServer. Verifying NIC ordering The pif-list command can be used to verify that NIC ordering is consistent across your XenServer Hosts. Review the MAC address and carrier (link state) parameters associated with each PIF to verify that the devices discovered (eth0, eth1, etc.) correspond to the appropriate physical port on the server.
xe pif-list params=uuid,device,MAC,currently-attached,carrier,management, \ IP-configuration-mode uuid ( RO) device MAC currently-attached management IP-configuration-mode carrier ( ( ( ( ( ( : RO): RO): RO): RO): RO): RO): 1ef8209d-5db5-cf69-3fe6-0e8d24f8f518 eth0 00:19:bb:2d:7e:8a true true DHCP true
If the hosts have already been joined in a pool, add the host-uuid parameter to the pif-list command to scope the results to the PIFs on a given host. Re-ordering NICs
It is not possible to directly rename a PIF, although you can use the pif-forget and pif-introduce commands to achieve the same effect with the following restrictions:
The XenServer Host must be standalone and not joined to a resource pool. Re-ordering a PIF configured as the host's management interface requires additional steps which are included in the example below. Because the management interface must first be disabled the commands must be entered directly on the host console.
For the example configuration shown above use the following steps to change the NIC ordering so that eth0 corresponds to the device with a MAC address of 00:19:bb:2d:7e:7a: 1. Use XenCenter or the vm-shutdown command to shut down all VMs in the pool to force existing VIFs to be unplugged from their networks.
3.
4. xe host-management-disable
5.
Use the pif-forget command to remove the two incorrect PIF records:
8.
Use the pif-introduce command to re-introduce the devices with the desired naming:
9. xe pif-introduce device=eth0 host-uuid=<host UUID> mac=00:19:bb:2d:7e:7a 10. xe pif-introduce device=eth1 host-uuid=<host UUID> mac=00:19:bb:2d:7e:8a
11. Use the pif-list command again to verify the new configuration:
12.
xe pif-list params=uuid,device,MAC
13. Use the pif-reconfigure-ip command to reset the management interface IP addressing configuration. See Command line interface for details on the parameters of the pif-reconfigure-ip command.
14.
15. Use the host-management-reconfigure command to set the management interface to the desired PIF and re-enable external management connectivity to the host:
16.
xe host-management-reconfigure pif-uuid=728d9e7f-62ed-a4772c71-3974d75972eb
Networking Troubleshooting
If you are having problems with configuring networking, first ensure that you have not directly modified any of the control domain ifcfg-* files directly. These files are directly managed by the control domain host agent, and changes will be overwritten.
$ xe pif-list device=eth0
Next, set the following parameter on the PIF to disable TX offload:
It is recommended that you ensure networking configuration is set up correctly before creating a resource pool, as it is usually easier to recover from a bad configuration in a non-pooled state. The host-management-reconfigure and host-management-disable commands affect the XenServer Host on which they are run and so are not suitable for use on one host in a pool to change the configuration of another. Run these commands directly on the console of the XenServer Host to be affected, or use the xe -s, -u, and -pw remote connection options.
When the xapi service starts, it will apply configuration to the management interface first. The name of the management interface is saved in the /etc/xensource-inventory file. In extreme cases, you can stop the xapi service by running service xapi stop at the console, edit the inventory file to set the management interface to a safe default, and then ensure that the ifcfg files in /etc/sysconfig/network-scripts have correct configurations for a minimal network configuration (including one interface and one bridge; for example, eth0 on the xenbr0 bridge).