Score:0

How to enable external access to the Virtual machine on private link?

cn flag

I would like to benchmark virtual networking of KVM-QEMU. For this purpose, I connect two servers (server 1, and server 2) with one wire. I use server 1 to run the QEMU VM and I want to access this VM from server 2.
Here's the overview of the configuration.

           o ens5f0    (ip 192.168.11.12/24)
           |
           | (server 2)
 ------------------------- (Host/Network boundary)
           "
           "
 ------------------------- (Host/Network boundary)
           | (server 1)
           |
           o ens5f0 
           |
           o br0.      (ip 192.168.11.11/24)
           |
 ------------------------- (VM/Host boundary)
           | (guest)
           |
           o (enp0s2) inside VM
             (ip 192.168.11.77/24 (from dhcp))

I followed the documentation here. I configure a bridge on server 1 and add interface ens5f0 to it.

server 1
---------------------
ip link add br0 type bridge
ip link set ens5f0 master br0
ip addr flush dev ens5f0
ip addr add 192.168.11.11/24 dev br0
ip link set dev br0 up
dnsmasq --interface=br0 --bind-interfaces --dhcp-range=192.168.11.12,192.168.11.254
ip link set dev ens5f0 up

Then I launch QEMU using the following command.

server 1
---------------------
qemu-system-x86_64 \                                                                                                         
   -initrd initrd.img-5.4.0-84-generic \                                                                                     
   -kernel vmlinuz-5.4.0-84-generic \                                                                                        
   -nographic -monitor none -serial stdio\                                                                                   
   -append 'root=/dev/vda1 console=ttyS0' \                                                                                  
   -machine q35 -cpu host \                                                                                                  
   -drive "file=${disk_img_snapshot},format=qcow2,if=virtio" \                                                               
   -nic bridge,br=br0,model=virtio-net-pci \                                                                                 
   -enable-kvm \                                                                                                             
   -m 2G \                                                                                                                  
   -smp 4 \                                                                                                                 
;  

Inside the VM, interface enp0s2 gets ip address 192.168.11.77/24.

VM
--------------------
~$ sudo ip addr show enp0s2
2: enp0s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000                                  
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.77/24 brd 192.168.11.255 scope global dynamic noprefixroute enp0s2                                                 
       valid_lft 3531sec preferred_lft 3531sec

The ping command has access to this ip address from server 1 and the ip address 192.168.11.11 is also accessable from the VM.

On the second server, I configure the IP address to be static and equal to 192.168.11.12/24.

server 2
------------------------
$ ip addr add 192.168.11.12/24 dev ens5f0

$ ping 192.168.11.11
PING 192.168.11.11 (192.168.11.11) 56(84) bytes of data.
64 bytes from 192.168.11.11: icmp_seq=1 ttl=64 time=0.327 ms
64 bytes from 192.168.11.11: icmp_seq=2 ttl=64 time=0.153 ms

The issue is that ip address 192.168.11.77 could not be reached from server 2 and the VM cannot ping server 2. How could could I enable external access to the VM on this link?

Score:0
sg flag

You can run tcpdump -i br0 in order to see whats on the route.

ph flag
A bit more explanation of how this answers the question would improve the answer
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.