~优化新手引导中启用IP转发的提示及实现逻辑

This commit is contained in:
juewuy
2026-08-02 10:39:00 +08:00
parent c2d9e441d2
commit 0ab3fade1b
3 changed files with 8 additions and 3 deletions
+5 -2
View File
@@ -75,10 +75,13 @@ forwhat() {
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then
separator_line "-"
content_line "\033[33m$UG_IP_FORWARD_WARN\033[0m"
[ "$systype" = 'container' ] && content_line "\033[31m$UG_CONTAINER_WARN\033[0m"
read -r -p "$COMMON_INPUT_R" res
[ "$res" = 1 ] && {
echo 'net.ipv4.ip_forward = 1' >>/etc/sysctl.conf
sysctl -w net.ipv4.ip_forward=1
grep -q '^net\.ipv4\.ip_forward' /etc/sysctl.conf \
&& sed -i 's/^net\.ipv4\.ip_forward.*/net.ipv4.ip_forward = 1/' /etc/sysctl.conf \
|| echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
}
fi
# 禁止docker启用的net.bridge.bridge-nf-call-iptables