Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Add Network Interface To KVM Guest

Use the steps below to add a network interface to your guest.

Use Case

A good use-case for this is if you are setting up a NAT/gateway on a guest, who will need the normal public interface to the outside world, and another network interface for the internal private LAN that the other guests are connected to.

Steps

GUEST_ID="my-guest-name"
NETWORK_NAME="privatenet"
TYPE="network"

virsh attach-interface \
  --domain $GUEST_ID \
  --type $TYPE \
  --source $NETWORK_NAME  \
  --model virtio \
  --config \
  --live

You may wish to change type to "bridge" if you are using a traditional bridge interface from your host, instead of a defined KVM network.

References

Last updated: 19th July 2021
First published: 19th July 2021