Skip to content

Commit

Permalink
network: add publicly mapped ports to FORWARD table
Browse files Browse the repository at this point in the history
Allow publicly mapped ports to be made public beyond the host.  This is
needed for distros like Fedora and RHEL which have a reject all rule at
the end of their FORWARD table.

Docker-DCO-1.1-Signed-off-by: Josh Poimboeuf <[email protected]> (github: jpoimboe)
  • Loading branch information
jpoimboe committed Jan 28, 2014
1 parent d4ea630 commit db250f7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ func (c *Chain) Forward(action Action, ip net.IP, port int, proto, dest_addr str
} else if len(output) != 0 {
return fmt.Errorf("Error iptables forward: %s", output)
}

fAction := action
if fAction == Add {
fAction = "-I"
}
if output, err := Raw(string(fAction), "FORWARD",
"!", "-i", c.Bridge,
"-o", c.Bridge,
"-p", proto,
"-d", daddr,
"--dport", strconv.Itoa(port),
"-j", "ACCEPT"); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Error iptables forward: %s", output)
}

return nil
}

Expand Down

0 comments on commit db250f7

Please sign in to comment.