KVM Plugin - use a second NIC only for KVM

  • In need of a bit of help and pointers.

    I don't recall if this was discussed and tried already on the forum.


    I followed the wiki to a T, to prep everything to run a VM (ZorinOS for that matter) but the Network is bugging me.

    It mentions that it's possible to use a seperate NIC but the instructions aren't very clear (to me):


    Configuring a Separate physical interface on the system

    Quote
    • If you have two physical network interfaces on your server you can reserve one of them for KVM. Just don't set it to OMV.
    • Depending on the type of connection (USB, pcie,…) you must choose the appropriate method to attach this hardware to the VM. Once a VM is configured you can attach the hardware in the VMs tab, choosing the appropriate button in each case on the top bar.


    My board has 4x NICs (enp2s0 >> enp5s0) which only enp2s0 is in use on OMV.

    The other 3 are now free and without any config.


    What I want is to have a second CAT7 cable attached to enp5s0 to use exclusively on the KVM plugin.


    How should I add that NIC?


    I've been struggling on how to add it.


    [EDIT]

    While I was writting the above, just had an epiphany (or I just read it with better eyes)

    "Go to pcie devices and search for the proper one"


    It's there in plain sight after you know where to look:



    Now, the question is, how to know which is which?


    Can I assume that enp5s0 corresponds to pcie [05]----00.0 Intel Corporation Ethernet Controller I226-V


    ???

  • My guess is yes.

    The output from lspci in the code box should look exactly like the boxes in the screenshot. It appears that that command has been run with -vt flags.

    Crosscheck with going to /sys/class/net and do ls -l.


    For me it shows in normal lspci:
    02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)

    and in /sys/class/net a link from eno1 to the pci tree

    lrwxrwxrwx 1 root root 0 Feb 14 15:47 eno1 -> ../../devices/pci0000:00/0000:00:13.2/0000:02:00.0/net/eno1 (that's Host bridge... to a pci bridge to the actual ethernet controller)

    and this is what is shown in lspci with -vt flags:

    -[0000:00]-+-00.0 Intel Corporation Gemini Lake Host Bridge

    ...

    +-13.2-[02]----00.0 Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller


    Take it with a grain of salt. This was a fun google search and yielded results quite fast. This result was great!

  • I do this with my VM's.


    It's easy to do. Add the extra NIC's to OMV so that they are in the list of NIC's but don't enable them (leave IPv4 and IPv6 disabled).


    Then in the KVM plugin, assign them to a KVM network.


    You can then add them to a VM. The NIC is then use by the VM and not by OMV. The KVM network behaves like a virtual ethernet switch and can be used by multiple VM's to connect them to the LAN


    As for figuring out which NIC is which, I use ip a to get the interface names and then reference the port numbering on the card/board specifications.


    For example, I have one port on my motherboard and 2 ports on an add in card. The port on my motherboard is enp9s0 and the addin card is enp7s0f0 and enp7s0f1. enp7s0f0 is the first port on the card and enp7s0f1 is the second port.


    ***edit***

    I should have also noted or explained further that the nic names are also visible in OMV, but I like to confirm with ip a as this also shows the state of the port (UP/DOWN) to confirm the cable is connected and linking to the LAN. This can also help determine the correct port.

  • It's easy to do

    I'll need a bit of visual aid on this, if you don't mind.


    I tried to do the same and, on OMV network was simple:

    Just made a new ethernet interface and pointed to the enp5s0 and no DHCP4 && 6:



    On the KVM plugin, I'm lost. What do I use here?


  • The best way to assign a network card exclusively to a VM is to use the "add PCI device" function from the KVM plugin.

    Otherwise, the fixed IP assigned to OMV will be detected on all network adapters connected to the LAN, physically present in the machine.

    See:


  • No problem, here are some screen shots to help illustrate.


    As mentioned, my omv interfaces are enp9s0, enp7sof0 and enp7s0f1. I have tagged them to help identify them.


    create a kvm macvtap network on one of the ports (I am using enp7s0f0 for my vm's and have named it macvtap_enp7s0f0 for easy identification)


    In the vm creation, you pick that named macvtap as your network/interface, preferably using virtio for maximum performance)


    If you don't define the kvm network as a macvtap, it can only be used as a passthrough to one vm. The macvtap allows it to operate as a virtual switch and can be shared with other vm's


    With my VM's, I have used virt-manager in a docker (example int he compose plugin) to easily add a second NIC that is on the kvm "default" network.


    With this configuration, the virtual nic on the macvtap gets a LAN IP (192.168.2.x in my case), and the virtual NIC on the kvm default network gets an ip in the 192.168.122.x range with 192.168.122.1 being the KVM/Host gateway. My 192.168.2.x network is 1Gb but the 192.168.122.x "internal" network operates at 10Gb allowing the VM to access things on the host at 10Gb for mounting shares, accessing databases, etc.



    ***edit***

    One more point to make as an added bonus. Using the KVM default network 192.168.122.x is also available to your docker containers if you are running anything that does not allow a container to communicate with other containers using a container name or can't address the host based on LAN ip. Essentially this allows for 10Gb access between KVM/docke/host completely "inside the box"

  • Thank you all for the inputs.


    I managed to make it work easy by following the wiki instructions (but not on the NIC that OMV uses) for a bridge connection on OMV.

    I just made it with in the OMV --> Network --> Interfaces but pointed it to enp5s0:



    The bridge received an IP on the same range of the LAN.


    After, it was just a matter of adding it to the Services --> KVM --> Networks:



    And configure the VM to use it:




    It worked without issues.


    Perhaps this will work with only one VM (don't know if the bridge will be exclusive to it or shared) but for now, it's enough to start learning.

  • A bridge will work just fine to give all vm's a LAN IP. I have never been able to get a bridge working correctly for myself on the main OMV NIC, so I started using the macvtap route I showed you. It essentially works the same as doing the bridge on a different port like you did, but is just quicker and easier to set up.


    If I had only one NIC on the system I would have to dig into the bridge option deeper but with multiple NIC, it's not a requirement.


    I also prefer to use another nic for my VM's just for bandwidth purposes. I tend to push large files around both at home and over the internet to the office via one of my vm's. This way I don't have any "bottle neck slow downs" if both are happening simultaneously.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!