<div dir="ltr">Hi Michael,<div>Thanks for answering my question. There was no such file /var/lib/libvirt/dnsmasq/default.conf, so I created one. However, it still doesn't work after killing the existing dnsmasq and restarted the libvirtd. </div>
<div><br></div><div>================</div><div><div>[root@devmachine dnsmasq]# ls -l /var/lib/libvirt/dnsmasq/default.conf</div><div>-rw-r--r-- 1 root root 21245 Feb 14 10:33 /var/lib/libvirt/dnsmasq/default.conf</div></div>
<div><br></div><div># added one line trying to assign 192.168.122.200 to container c1</div><div><div>[root@devmachine dnsmasq]# tail -1 /var/lib/libvirt/dnsmasq/default.conf</div><div>dhcp-host=c1,192.168.122.200</div></div>
<div><br></div><div># kill existing dnsmasq<br></div><div><div>[root@devmachine dnsmasq]# ps -ef | grep dns</div><div>nobody 29325 1 0 10:37 ? 00:00:00 /usr/sbin/dnsmasq --strict-order --local=// --domain-needed --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --bind-interfaces --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts</div>
</div><div><br></div><div><div>[root@devmachine dnsmasq]# kill -9 29325</div><div>[root@devmachine dnsmasq]# !ps</div><div>ps -ef | grep dns</div><div>root 30695 34063 0 11:02 pts/3 00:00:00 grep dns</div></div><div>
<br></div><div># restart libvirtd</div><div><div>[root@devmachine dnsmasq]# service libvirtd restart</div><div>Stopping libvirtd daemon: [ OK ]</div><div>Starting libvirtd daemon: [ OK ]</div>
</div><div><br></div><div># still no conf-file is given to dnsmasq</div><div><div>[root@devmachine dnsmasq]# !ps</div><div>ps -ef | grep dns</div><div>nobody 30782 1 0 11:03 ? 00:00:00 /usr/sbin/dnsmasq --strict-order --local=// --domain-needed --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --bind-interfaces --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts</div>
<div>root 30829 34063 0 11:03 pts/3 00:00:00 grep dns</div></div><div>================<br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 14, 2014 at 1:33 AM, Michael H. Warfield <span dir="ltr"><<a href="mailto:mhw@wittsend.com" target="_blank">mhw@wittsend.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, 2014-02-13 at 16:23 +0800, Mingjiang Shi wrote:<br>
> Hello,<br>
> I run lxc container on centos and want to my container to start with a<br>
> static IP address.<br>
><br>
><br>
> After some investigation, I figured out that the dnsmasq is started by<br>
> libvirtd to provide DNS and DHCP service to the container. However, I<br>
> cannot figure out how to reserve ip address for a specific host in the<br>
> dnsmasq config file.<br>
><br>
><br>
> Meanwhile, in the ps out, it looks like no config file is given when<br>
> start the dnsmasq daemon, which doesn't sound right.<br>
<br>
</div>No, that doesn't sound right. Are you sure there isn't a dnsmasq config<br>
file in /var/lib/libvirt/dnsmasq/default.conf ? I take it that it's<br>
ignoring the default config file /etc/dnsmasq.conf options.<br>
<br>
According to the doco, dnsmasq does support static address assignments,<br>
so it's just a matter of getting to the correct conf file. That may be<br>
a libvirt configuation setting there.<br>
<div class="">><br>
> nobody 12531 1 0 Feb12 ? 00:00:01 /usr/sbin/dnsmasq<br>
> --strict-order --local=// --domain-needed<br>
> --pid-file=/var/run/libvirt/network/default.pid --conf-file=<br>
> --except-interface lo --bind-interfaces --listen-address 192.168.122.1<br>
> --dhcp-range 192.168.122.2,192.168.122.254<br>
> --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases<br>
> --dhcp-lease-max=253 --dhcp-no-override<br>
> --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile<br>
> --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts<br>
><br>
><br>
><br>
> As a workaround, I configured a static ip address in the container<br>
> like how we configure an ip address to a standard Linux box. However,<br>
> I want to know how to config dnsmasq to give static ip address to a<br>
> specific container because I may run lots of containers. Appreciate<br>
> any response and idea. Thanks!<br>
><br>
><br>
> --<br>
> Thanks<br>
> -Mingjiang<br>
><br>
</div>> --<br>
> This message has been scanned for viruses and<br>
> dangerous content by MailScanner, and is<br>
> believed to be clean.<br>
<div class="">> _______________________________________________<br>
> lxc-users mailing list<br>
> <a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.linuxcontainers.org</a><br>
> <a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a><br>
<br>
--<br>
</div>Michael H. Warfield (AI4NB) | <a href="tel:%28770%29%20978-7061" value="+867709787061">(770) 978-7061</a> | mhw@WittsEnd.com<br>
/\/\|=mhw=|\/\/ | (678) 463-0932 | <a href="http://www.wittsend.com/mhw/" target="_blank">http://www.wittsend.com/mhw/</a><br>
NIC whois: MHW9 | An optimist believes we live in the best of all<br>
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!<br>
<br>
<br>_______________________________________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks<br>-Mingjiang
</div>