netconfig: use sysctl format for easier copy&paste
This commit is contained in:
parent
9012520052
commit
725262d376
@ -678,16 +678,17 @@ func applyFirewall(dir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applySysctl() error {
|
func applySysctl() error {
|
||||||
if err := ioutil.WriteFile("/proc/sys/net/ipv4/ip_forward", []byte("1"), 0644); err != nil {
|
for _, ctl := range []string{
|
||||||
return fmt.Errorf("sysctl(net.ipv4.ip_forward=1): %v", err)
|
"net.ipv4.ip_forward=1",
|
||||||
}
|
"net.ipv6.conf.all.forwarding=1",
|
||||||
|
"net.ipv6.conf.uplink0.accept_ra=2",
|
||||||
if err := ioutil.WriteFile("/proc/sys/net/ipv6/conf/all/forwarding", []byte("1"), 0644); err != nil {
|
} {
|
||||||
return fmt.Errorf("sysctl(net.ipv6.conf.all.forwarding=1): %v", err)
|
idx := strings.Index(ctl, "=")
|
||||||
}
|
key, val := ctl[:idx], ctl[idx+1:]
|
||||||
|
fn := strings.Replace(key, ".", "/", -1)
|
||||||
if err := ioutil.WriteFile("/proc/sys/net/ipv6/conf/uplink0/accept_ra", []byte("2"), 0644); err != nil {
|
if err := ioutil.WriteFile("/proc/sys/"+fn, []byte(val), 0644); err != nil {
|
||||||
return fmt.Errorf("sysctl(net.ipv6.conf.uplink0.accept_ra=2): %v", err)
|
return fmt.Errorf("sysctl(%v=%v): %v", key, val, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user