qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom DNS for a VM


From: Peter Maydell
Subject: Re: Custom DNS for a VM
Date: Mon, 30 May 2022 14:42:19 +0100

On Mon, 30 May 2022 at 13:56, Thomas Huth <thuth@redhat.com> wrote:
>
> On 26/05/2022 12.01, Narcis Garcia wrote:
> > Is it possible to specify an explicit DNS IP for a VM in user mode 
> > networking?
> >
> > For example, host uses 1.2.3.4 as nameserver at /etc/resolv.conf
> > And I want a user mode VM makes queries to a different nameserver.
> >
> > Context: Qemu 5.2.0 in Debian 11 host. All command-line.
>
> I've never tried, but -netdev user has a "dns" option, so have you tried
> something like already:
>
>   qemu-system-... -nic user,dns=8.8.8.8

I believe that that will set the IP address that the guest
VM sees as its DNS server (ie what it is told by the DHCP
server and the IP address that slirp responds to DNS requests
on), but it doesn't affect how the slirp backend actually
resolves requests made to slirp's stunt DNS server.

Looking quickly through the source it looks like
(a) if the guest is using the slirp DNS server then there's
no way to configure how slirp resolves those requests
(on Linux it will look for a nameserver IP in resolv.conf,
and ask that one)
(b) if you configure your guest to ignore what the slirp
DHCP server tells it to use for DNS, then doing DNS to any
DNS server you like will probably work (at least, as well as
any other UDP or TCP outbound from the guest)
(c) it might be possible to get QEMU to simply not create
the slirp DNS server, but I'm not sure what the syntax
for that is; and in any case you would need to tell the
guest what DNS server to actually use somehow

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]