Configure iptables forward policy when ip forwarding is enabled

Signed-off-by: Leonardo Nodari <me@leonardonodari.it>
This commit is contained in:
Leonardo Nodari 2019-09-12 15:18:18 +02:00
parent b8f02469bc
commit 7e584c1d69
1 changed files with 5 additions and 5 deletions

View File

@ -34,11 +34,11 @@ func setupIPForwarding(enableIPTables bool) error {
if err := configureIPForwarding(true); err != nil {
return fmt.Errorf("Enabling IP forwarding failed: %v", err)
}
// When enabling ip_forward set the default policy on forward chain to
// drop only if the daemon option iptables is not set to false.
if !enableIPTables {
return nil
}
}
// Set the default policy on forward chain to drop only if the
// daemon option iptables is not set to false.
if enableIPTables {
if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
if err := configureIPForwarding(false); err != nil {
logrus.Errorf("Disabling IP forwarding failed, %v", err)