Browse code

Support hairpin NAT without going through docker server

Hairpin NAT is currently done by passing through the docker server. If
two containers on the same box try to access each other through exposed
ports and using the host IP the current iptables rules will not match the
DNAT and thus the traffic goes to 'docker -d'

This change drops the restriction that DNAT traffic must not originate
from docker0. It should be safe to drop this restriction because the
DOCKER chain is already gated by jumps that check for the destination
address to be a local address.

Docker-DCO-1.1-Signed-off-by: Darren Shepherd <darren.s.shepherd@gmail.com> (github: ibuildthecloud)

Darren Shepherd authored on 2014/03/04 13:53:57
Showing 1 changed files
... ...
@@ -66,7 +66,6 @@ func (c *Chain) Forward(action Action, ip net.IP, port int, proto, dest_addr str
66 66
 		"-p", proto,
67 67
 		"-d", daddr,
68 68
 		"--dport", strconv.Itoa(port),
69
-		"!", "-i", c.Bridge,
70 69
 		"-j", "DNAT",
71 70
 		"--to-destination", net.JoinHostPort(dest_addr, strconv.Itoa(dest_port))); err != nil {
72 71
 		return err