<div dir="ltr"><div><br></div><div>Does the libvirt has any capabilities to get the statistics of DHCP server ? How many packets received/sent ?</div><div>Is there a way to get those statistics if the APIs are not available ?</div><div><br></div>Thanks & Regards<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Santhosh Kumar Gunturu</div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 30, 2020 at 1:45 PM Laine Stump <<a href="mailto:laine@redhat.com">laine@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 4/28/20 12:01 PM, Daniel P. Berrangé wrote:<br>
> On Tue, Apr 28, 2020 at 08:51:45AM -0700, Santhosh Kumar Gunturu wrote:<br>
>> Okay. Thanks.<br>
>><br>
>> Do we have any facility APIs to set the DHCP Options via XML ?<br>
>> Default gateway ?<br>
<br>
libvirt has no supported method of specifying a default gateway other <br>
than the IP of the bridge device on the virtualization host it self, and <br>
DHCP clients on these networks will always end up getting their default <br>
gateway set to the IP address of that bridge. Fortunately (for you :-) <br>
that's not because libvirt is explicitly setting that address in the <br>
dnsmasq config file, but just because that's what dnsmasq does when no <br>
gateway address is specified in the config file.<br>
<br>
You would set this in the dnsmasq.conf file with dhcp-option, e.g.:<br>
<br>
   dhcp-option=option-router,192.168.122.5<br>
<br>
and recent libvirt (5.6.0 and newer) allows adding arbitrary lines to <br>
the dnsmasq.conf files it creates for its networks, using the <br>
<dnsmasq:options> element in the network XML. For details on how to do <br>
this, look at:<br>
<br>
   <a href="https://libvirt.org/formatnetwork.html#elementsNamespaces" rel="noreferrer" target="_blank">https://libvirt.org/formatnetwork.html#elementsNamespaces</a><br>
<br>
<br>
<br>
>> Dns-server ?<br>
<br>
Not exact, but<br>
<br>
<forwarder addr='8.8.8.8'/><br>
<br>
is *kind of* what you're looking for. It doesn't set the IP address sent <br>
back in the dhcp reply, but sets up the dnsmasq instance listening for <br>
the network to forward all requests on to 8.8.8.8 (you can also refine <br>
this to forward the requests for only certain domains, by adding <br>
"domain='<a href="http://example.com" rel="noreferrer" target="_blank">example.com</a>'" to the <forwarder> element).<br>
<br>
(If you *really* need to have the guest send DNS requests directly to <br>
the upstream DNS server rather than via dnsmasq, then you would need to <br>
use <dnsmasq:options> to set something like <br>
"dhcp-option=option-dns-server,8/8/8/8")<br>
<br>
>> domain-name ?<br>
<br>
domain can be set with "<domain name='<a href="http://example.com" rel="noreferrer" target="_blank">example.com</a>'/>".<br>
<br>
<br>
> <br>
> Everything is controlled through the XML document described here:<br>
> <br>
>     <a href="https://libvirt.org/formatnetwork.html" rel="noreferrer" target="_blank">https://libvirt.org/formatnetwork.html</a><br>
> <br>
> We don't have separate APIs for each piece of info - just the one<br>
> virNetworkDefineXML API that takes the XML document.<br>
> <br>
> Regards,<br>
> Daniel<br>
> <br>
<br>
</blockquote></div>