我要评分
获取效率
正确性
完整性
易理解

Configuring the Host Network

Create a host network device to support subsequent VM network configuration.

  1. Check the NIC used on the host.
    ip a

  2. Check the PCI node of the NIC.
    lshw -c network -businfo

  3. Check the maximum number of VFs allowed by the NIC.
    cat /sys/bus/pci/devices/0000:75:00.0/sriov_totalvfs

    • If this command is successfully executed, the device supports the single-root I/O virtualization (SR-IOV) solution. 7 in the command output indicates that seven vNICs can be created, and a maximum of seven VMs can use the vNICs.
    • If this command fails or the number of vNICs in the command output is less than the number of VMs to be deployed, select the second solution, that is, the bridge mode. This mode will cause extra computing performance loss and latency. To configure the bridge mode, see 6 and 7.
  4. Create VFs.
    echo 4 > /sys/bus/pci/devices/0000:75:00.0/sriov_numvfs

    You need to perform this step every time the server is restarted. You are advised to write this step in a file such as ~/.bashrc for automatic execution after each restart.

  5. Check the created VF nodes.
    lshw -c network -businfo

    If the following information is displayed, four vNICs are successfully created.

    1 to 5 have completed the creation of vNICs in the SR-IOV solution. You can skip the following steps.

    If the device does not support SR-IOV, you can perform the following steps to adopt the bridge solution.

    If the maximum number of VFs supported by the NIC in 3 is 2 and four VMs need to be deployed, you can adopt the SR-IOV solution for two VMs and the bridge solution for the other two.

  6. Check and back up the configuration file of the current NIC.
    cd /etc/sysconfig/network-scripts/
    cp ifcfg-eno5 ifcfg-eno5.bak
  7. Create a bridge configuration file ifcfg-br0 and modify the NIC configuration file.
    Migrate the IPADDR, NETMASK, GATEWAY, and DNS information in the NIC configuration file to the bridge configuration file.
    touch ifcfg-br0
    cat >ifcfg-br0 <<EOF
    TYPE=Bridge
    NAME=br0
    DEVICE=br0
    ONBOOT=yes
    BOOTPROTO=static
    IPADDR=XX.XX.XX.XX
    NETMASK=XX.XX.XX.XX
    GATEWAY=XX.XX.XX.XX
    DNS1=XX.XX.XX.XX
    EOF
    1. Modify IPADDR, NETMASK, GATEWAY, and DNS in the bridge configuration file based on the NIC configuration of the host.
    2. Delete the IPADDR, NETMASK, GATEWAY, and DNS configurations from the host NIC configuration file and add BRIDGE=br0 to the end of the file.

  8. Restart the libvirtd and NetworkManager services and reboot the server.
    systemctl restart libvirtd
    systemctl restart NetworkManager
    reboot
  9. Check whether br0 is successfully created.
    ip a

    If the following information is displayed, the bridge is created.