Slow network performance in Linux VMs
- Dominant language
- Swift
- Stars
- 35.5k
- Forks
- 1.8k
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 7
Description
**Describe the issue**
UTM provides very slow ip forwarding in bridged mode. The exact reasons to me are unclear.
I have Debian 11 (Linux 5.10) x86_64 installed (the version does not matter much) with 4 GB of RAM, 4 CPU cores, and a network card in bridged mode. The virtual machine runs on 192.168.1.2 host, and sits on 192.168.1.175. Gateway is 192.168.1.1. Let's say I want to analyse the traffic in my VM from 192.168.1.0/24 (e.g. my 192.168.1.2 host), for that I do the following:
- Enable packet forwarding:
`sysctl -w net.ipv4.ip_forward=1`.
- Enable SNAT:
`iptables -t nat -A POSTROUTING ! -d 192.168.1.0/24 -o $ADAPTER -j SNAT --to-source 192.168.1.175`
Here `$ADAPTER` is my VM NIC (e.g. `enp0s7`)
My connection is ≈500/500 Mbps. I can get these speeds on both host and guest if I run `speedtest` there. Whenever I change the gateway to 192.168.1.175 in any machine on 192.168.1.0/24 (let's say host, but it does not matter too much), its network speed (verified by `speedtest` again) goes down to approximately:
- 130-160/520 Mbps on `e1000` adapter
- 140/530 Mbps on `virtio-net-pci` adapter
- no connection on `vmxnet3` adapter (the VM gets no IP).
I could have imagined the issue to be in the hardware/Linux guest configuration, but with VMware Fusion 12.2.1 I am able to reach around:
- 200-220/330 Mbps with `e1000` adapter
- 375-390/375 Mbps with `vmxnet3` adapter
All done on exactly the same machine. VMware Fusion uses Apple networking on macOS 11 and macOS 12, so it should technically be in the same conditions UTM is. I personally expected to get better results than VMware.
**Configuration**
* UTM Version: 2.1.2 and 3.0.2
* OS Version: macOS 12.1, but I got similar results on macOS 11.
* Intel
I can upload a test vm, but really any Linux distro would do, it is just all about installing iptables and running two commands. The results do not change if I allocate 8 cores and 8 GB or RAM to the VM, so it is not obviously performance bound. Disabling the hypervisor makes it cap around 120 Mbps.
At this step I have three questions:
- Are my VM settings correct if my goal is to get maximum networking performance? Perhaps I should try Apple Linux support (it is not obvious to me how to quickly try it though)?
- Do the results I get correspond to the current state of UTM development?
- Are there any plans to improve networking performance in UTM? In this case the issue can be considered a feature request.
Contributor guide
Assessment
This issue has not been assessed yet.