Update network.sh

This commit is contained in:
spiritLHLS 2023-02-23 22:03:19 +08:00 committed by GitHub
parent fb8610e526
commit 58bd060078
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,16 +20,18 @@ NET_ADDR=${NET_ADDR::-1}
# 获取网关地址
GATEWAY=$(ip route | awk '/default/ {print $3}')
# 创建虚拟网桥的配置文件
echo "# This file is generated by create_vmbr0.sh script" > /tmp/$BRIDGE_NAME.conf
echo "auto $BRIDGE_NAME" >> /tmp/$BRIDGE_NAME.conf
echo "iface $BRIDGE_NAME inet static" >> /tmp/$BRIDGE_NAME.conf
echo " address $IP_ADDR" >> /tmp/$BRIDGE_NAME.conf
echo " netmask $SUBNET_MASK" >> /tmp/$BRIDGE_NAME.conf
echo " gateway $GATEWAY" >> /tmp/$BRIDGE_NAME.conf
echo " bridge_ports none" >> /tmp/$BRIDGE_NAME.conf
echo " bridge_vlan_aware 1" >> /tmp/$BRIDGE_NAME.conf
echo " vlan_ids 100" >> /tmp/$BRIDGE_NAME.conf
# 创建虚拟网桥
cat << EOF > /etc/network/interfaces.d/$BRIDGE_NAME.conf
# This file is generated by create_vmbr0.sh script
auto $BRIDGE_NAME
iface $BRIDGE_NAME inet static
address $IP_ADDR
netmask $SUBNET_MASK
gateway $GATEWAY
bridge_ports none
bridge_vlan_aware 1
vlan_ids 100
EOF
# 将配置文件移动到网络接口配置目录
mv /tmp/$BRIDGE_NAME.conf /etc/network/interfaces.d/$BRIDGE_NAME.conf
# 重启网络服务以应用更改
systemctl restart networking.service