The subject heading is a repetition of many before, since around 2010, all asking for a solution. I just want to point out two errors in the error message itself.
Virtualmin prints the error message: “It appears that DHCP is being used to dynamically configure your network interfaces, … Using a static IP address is strongly recommended with Virtualmin.”
Almost every cloud server gets a static IP address via DHCP. The DHCP protocol is just a mechanism used here for assigning a static IP address good for the life of the server. The IP address is dynamically configured only in the sense that it is assigned when the server boots. But it’s already a static IP address, and there is no need to ask the user to use a static IP address.
Virtualmin prints the error message: “this system is not setup to use itself as a DNS server. Either add 127.0.0.1 to the list of DNS servers…”. This too may be incorrect in some or many situations.
There is no guarantee that /etc/resolv.conf is consulted by the resolver library. In Ubuntu 20.04, for example, if you use the command “resolvectl status”, it will print the DNS servers in use, and there need not be any overlap between these and the ones listed in /etc/resolv.conf.
Virtualmin should detect the actual DNS servers in use by whatever mechanism applies, and not simply search the /etc/resolv.conf file.