mirror of
https://github.com/thelittlerocket/pve.git
synced 2025-02-01 02:29:01 +08:00
Update network.sh
This commit is contained in:
parent
fb8610e526
commit
58bd060078
1 changed files with 14 additions and 12 deletions
26
network.sh
26
network.sh
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue