Skip to content

Instantly share code, notes, and snippets.

@goldmann
Created January 20, 2014 14:27
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save goldmann/8520776 to your computer and use it in GitHub Desktop.
diff --git a/network.go b/network.go
index 22ea8ba..d4cbabd 100644
--- a/network.go
+++ b/network.go
@@ -10,6 +10,7 @@ import (
"github.com/dotcloud/docker/utils"
"log"
"net"
+ "os/exec"
"strconv"
"sync"
"syscall"
@@ -466,8 +467,14 @@ func (alloc *IPAllocator) run() {
}
if _, inUse = alloc.inUse[newNum]; !inUse {
- // We found an unused IP
- break
+ _, err := exec.Command("arping", "-f", "-c", "1", "-q", "-I", "docker0", intToIP(newNum).String()).Output()
+ if err != nil {
+ // We found an unused IP
+ break
+ } else {
+ // Address is already used by some other host on network
+ continue
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment