[lxc-users] Centos: how to specify static ip address to container

Michael H. Warfield mhw at WittsEnd.com
Thu Feb 13 17:33:20 UTC 2014


On Thu, 2014-02-13 at 16:23 +0800, Mingjiang Shi wrote:
> Hello,
> I run lxc container on centos and want to my container to start with a
> static IP address.  
> 
> 
> After some investigation, I figured out that the dnsmasq is started by
> libvirtd to provide DNS and DHCP service to the container. However, I
> cannot figure out how to reserve ip address for a specific host in the
> dnsmasq config file. 
> 
> 
> Meanwhile, in the ps out, it looks like no config file is given when
> start the dnsmasq daemon, which doesn't sound right.

No, that doesn't sound right.  Are you sure there isn't a dnsmasq config
file in /var/lib/libvirt/dnsmasq/default.conf ?  I take it that it's
ignoring the default config file /etc/dnsmasq.conf options.

According to the doco, dnsmasq does support static address assignments,
so it's just a matter of getting to the correct conf file.  That may be
a libvirt configuation setting there.
> 
> nobody   12531     1  0 Feb12 ?        00:00:01 /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
> 
> 
> 
> As a workaround, I configured a static ip address in the container
> like how we configure an ip address to a standard Linux box. However,
> I want to know how to config dnsmasq to give static ip address to a
> specific container because I may run lots of containers. Appreciate
> any response and idea. Thanks!
> 
> 
> -- 
> Thanks
> -Mingjiang
> 
> -- 
> This message has been scanned for viruses and 
> dangerous content by MailScanner, and is 
> believed to be clean. 
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users

-- 
Michael H. Warfield (AI4NB) | (770) 978-7061 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 465 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20140213/a0c1dd3d/attachment.pgp>


More information about the lxc-users mailing list