I know an openvz just try to ping IP address before start the container, and if it is pings (already exists somewhere in the network), the container will not start. I can’t see the same function in LXC, so i think to write some simple script and use it with lxc.hook.pre-start - how do you think, is it good idea?
Yeah, that would work fine.
In general we tend to prefer DHCP for IP configuration, partly because it deals with that for you (both by tracking leases AND by pinging any address it wants to hand out).
Hey, @stgraber ! Glad to see you again!
Yeah, think so too. Wrote a small script:
#!/bin/bash for ip in "$@"; do ip=`echo $ip | cut -f1 -d'/'` ping -c1 $ip > /dev/null; if [ $? -eq 0 ]; then echo "/!\ $ip exists. Aborting container start." | tee >(logger -t 'LXC'); exit 1; fi done
Looks like it works!