[Lxc-users] Static IP in containers

Serge Hallyn serge.hallyn at ubuntu.com
Thu Nov 7 16:59:44 UTC 2013


Quoting Robin Monjo (robin.monjo at applidget.com):
> Thank you, it does set the correct IP but I can't reach internet now. Any idea ?

you'll need to set a route and resolv.conf, which lxc doesn't do.  You
should be able to do that with a lxc.script.up script, though, so

cat > /usr/share/lxc/hooks/setroute << EOF
#!/bin/sh
route add -net default 10.0.3.1
echo "nameserver 10.0.3.1" > /etc/resolvconf/resolv.conf.d/base
EOF
chmod ugo+x /usr/share/lxc/hooks/setroute
echo "lxc.network.script.up = /usr/share/lxc/hooks/setroute" > /var/lib/lxc/$container/config

-serge




More information about the lxc-users mailing list