Update build_nat_network.sh

This commit is contained in:
spiritLHLS 2023-04-10 14:40:44 +08:00 committed by GitHub
parent cc2d26906d
commit 90aeeb0fd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,6 +62,14 @@ if ! command -v iptables &> /dev/null; then
fi
iptables -t nat -A POSTROUTING -j MASQUERADE
sysctl net.ipv4.ip_forward=1
if grep -q "^net.ipv4.ip_forward=1" /etc/sysctl.conf; then
if grep -q "^#net.ipv4.ip_forward=1" /etc/sysctl.conf; then
sed -i 's/^#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
fi
else
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
fi
sysctl -p
# 重启配置
service networking restart