21 lines
428 B
Go
21 lines
428 B
Go
|
package bridge
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"io/ioutil"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
IPV4_FORW_CONF_FILE = "/proc/sys/net/ipv4/ip_forward"
|
||
|
PERM = 0644
|
||
|
)
|
||
|
|
||
|
func SetupIPForwarding(i *Interface) error {
|
||
|
// Sanity Check
|
||
|
if i.Config.EnableIPForwarding == false {
|
||
|
return fmt.Errorf("Unexpected request to enable IP Forwarding for: %v", *i)
|
||
|
}
|
||
|
// Enable IPv4 forwarding
|
||
|
return ioutil.WriteFile(IPV4_FORW_CONF_FILE, []byte{'1', '\n'}, PERM)
|
||
|
}
|