How to add a NIC to a CentOS7 KVM guest

Issues related to configuring your network
Post Reply
kvashishta
Posts: 66
Joined: 2015/02/15 18:35:55

How to add a NIC to a CentOS7 KVM guest

Post by kvashishta » 2015/02/20 17:15:46

Team,

I have spent a few hours googling this but am not able to find any direct steps to accomplish this.

On host:
[root@kvm home]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:13:3b:0f:43:de brd ff:ff:ff:ff:ff:ff
3: enp6s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:13:3b:0f:43:df brd ff:ff:ff:ff:ff:ff
4: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master virbr0 state UP qlen 1000
link/ether 80:c1:6e:df:0e:f2 brd ff:ff:ff:ff:ff:ff
5: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 80:c1:6e:df:0e:f2 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
inet 192.168.1.94/24 brd 192.168.1.255 scope global virbr0
valid_lft forever preferred_lft forever
8: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master virbr0 state UNKNOWN qlen 500
link/ether fe:54:00:07:75:56 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fe07:7556/64 scope link
valid_lft forever preferred_lft forever

So, I would like to "give" the NIC corresponding to enp4s0 to the KVM guest.

Please let me know if you need more information.

Any ideas will be gratefully accepted. I appreciate the continued support. Regards,

Kartik Vashishta

aks
Posts: 2538
Joined: 2014/09/20 11:22:14

Re: How to add a NIC to a CentOS7 KVM guest

Post by aks » 2015/02/21 15:21:52

There "KVM official" way: http://www.linux-kvm.org/page/How_to_as ... T-d_in_KVM
PCI passthrough : https://www.linkedin.com/pulse/20140617 ... h-qemu-kvm which I think would require IOMMU/VT-d

But I'd go for adding the direct option in the KVM configuration file, so something like
<devices>
...
<interface type='direct'>
<source dev='en4ps0' mode='private'/>
</interface>
...
</devices>

User avatar
TrevorH
Forum Moderator
Posts: 23644
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to add a NIC to a CentOS7 KVM guest

Post by TrevorH » 2015/02/21 15:34:33

Do you actually want to dedicate the entire ethernet card to the guest? That's what you'll do if you attach it to the guest like that. If you just want another ethernet interface on the guest that _uses_ that ethernet card on the host then you should create a new bridge on the host and then set up a new virtual ethernet card on the guest that is bridged to that bridge.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

jimbo8098
Posts: 11
Joined: 2015/01/30 03:06:11

Re: How to add a NIC to a CentOS7 KVM guest

Post by jimbo8098 » 2015/02/21 16:06:05

Yup, with Trevor here, there's rarely much of a reason to dedicate an entire network card to one specific service. Even dedicating it to KVM isn't going to really be much use since if the reasons for you doing so are redundancy if the other card is inaccessible (most likely), then you are barking at the wrong tree with this fix since if the other card is down it's really likely to be a system-wide issue. It would be worth looking into hosting the KVM on an IDRAC card (http://www.dell.com/content/topics/glob ... _bell?c=us) or something similar if you were looking to have that kind of availability. Consider that these cards also allow remote ISO mounting and reboots too, which you can't do with a KVM unless you have availability of it.

If you are intending on using KVM then you would be best just tethering the daemon to a specific port instead of a specific IP like that, there's very little reason not to unless the system is really being put through it's paces on the other card.

User avatar
TrevorH
Forum Moderator
Posts: 23644
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to add a NIC to a CentOS7 KVM guest

Post by TrevorH » 2015/02/21 17:57:20

I wish the developers had chosen a different name for their hypervisor other than KVM. KVM meant Keyboard/Video/Mouse switch for years and now it means Kernel Virtual Machine too...
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply