Update build_nat_network.sh

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

View file

@ -62,6 +62,7 @@ if ! command -v iptables &> /dev/null; then
fi
iptables -t nat -A POSTROUTING -j MASQUERADE
sysctl net.ipv4.ip_forward=1
sysctl_path=$(which sysctl)
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
@ -69,7 +70,7 @@ if grep -q "^net.ipv4.ip_forward=1" /etc/sysctl.conf; then
else
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
fi
sysctl -p
${sysctl_path} -p
# 重启配置
service networking restart