mirror of
https://github.com/tnb-labs/panel.git
synced 2026-09-01 14:55:12 +08:00
feat: 添加启用ipv6转发
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"cmp"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -271,6 +272,11 @@ func (r *firewalld) Forward(rule Forward, operation Operation) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 启用 IP 转发
|
||||
_, _ = shell.Execf("sysctl -w net.ipv4.ip_forward=1")
|
||||
_, _ = shell.Execf("sysctl -w net.ipv6.conf.all.forwarding=1")
|
||||
_ = os.WriteFile("/etc/sysctl.d/99-acepanel-forward.conf", []byte("net.ipv4.ip_forward=1\nnet.ipv6.conf.all.forwarding=1\n"), 0644)
|
||||
|
||||
for _, protocol := range buildProtocols(rule.Protocol) {
|
||||
var ruleBuilder strings.Builder
|
||||
ruleBuilder.WriteString(fmt.Sprintf("firewall-cmd --zone=public --%s-forward-port=port=%d:proto=%s:", operation, rule.Port, protocol))
|
||||
|
||||
+2
-1
@@ -391,7 +391,8 @@ func (r *ufw) Forward(rule Forward, operation Operation) error {
|
||||
func (r *ufw) addForward(rule Forward) error {
|
||||
// 启用 IP 转发
|
||||
_, _ = shell.Execf("sysctl -w net.ipv4.ip_forward=1")
|
||||
_ = os.WriteFile("/etc/sysctl.d/99-acepanel-forward.conf", []byte("net.ipv4.ip_forward=1\n"), 0644)
|
||||
_, _ = shell.Execf("sysctl -w net.ipv6.conf.all.forwarding=1")
|
||||
_ = os.WriteFile("/etc/sysctl.d/99-acepanel-forward.conf", []byte("net.ipv4.ip_forward=1\nnet.ipv6.conf.all.forwarding=1\n"), 0644)
|
||||
|
||||
content, err := os.ReadFile(beforeRulesPath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user