Enabling Networking between KVM host and guests.

In this post, I describe how to realise L2 reachability between KVM host and guest on Arch Linux.
There are several interface mode on KVM guests. Here, I will use MacVTap (bridge mode).

0. Method 1, using ip command.

# Creating an macvlan interface binds to enp0s25.
sudo ip link add link enp0s25 macvlan0 type macvlan mode bridge

# Set an IP address.
# Make sure to use different IP address from physical interface's.
# or, just delete an IP address from physical interface.
sudo ip addr add dev macvlan0

# Erasing all routing tables.
sudo ip route flush dev enp0s25
sudo ip route flush dev macvlan0

# Adding routes
sudo ip route add dev macvlan0 src metric 0
sudo ip route add default via dev macvlan0

2. Using netctl to make it permanent.

vim /etc/netctl/macvlan0

Description='macvlan0 for kvm'
# The variable name is plural, but needs precisely one interface
# Optional static MAC Address for MACVLAN interface

netctl disable enp0s25
netctl enable macvlan0

That’s all