Update network.sh

This commit is contained in:
spiritLHLS 2023-02-23 21:47:22 +08:00 committed by GitHub
parent f26338b790
commit beaf942335
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,7 +13,7 @@ IFS='.' read -ra IP_ARR <<< "$IP_ADDR"
IFS='.' read -ra MASK_ARR <<< "$SUBNET_MASK" IFS='.' read -ra MASK_ARR <<< "$SUBNET_MASK"
NET_ADDR="" NET_ADDR=""
for ((i=0; i<4; i++)); do for ((i=0; i<4; i++)); do
NET_ADDR="$NET_ADDR$(( ${IP_ARR[$i]} & ${MASK_ARR[$i]} ))." NET_ADDR="${NET_ADDR}$((${IP_ARR[$i]} & ${MASK_ARR[$i]}))."
done done
NET_ADDR=${NET_ADDR::-1} NET_ADDR=${NET_ADDR::-1}
@ -22,8 +22,13 @@ GATEWAY=$(ip route | awk '/default/ {print $3}')
# 创建虚拟网桥并将其记录到PVE配置中 # 创建虚拟网桥并将其记录到PVE配置中
pvesh set /nodes/localhost/network/$BRIDGE_NAME \ pvesh set /nodes/localhost/network/$BRIDGE_NAME \
bridge_ports=none \ -content-type "application/json" \
bridge_vlan_aware=1 \ -put \
vlan_ids=100 \ -data \
addresses="$IP_ADDR/$SUBNET_MASK" \ '{
gateway="$GATEWAY" "bridge_ports": "none",
"bridge_vlan_aware": "1",
"vlan_ids": "100",
"addresses": "'"$IP_ADDR/$SUBNET_MASK"'",
"gateway": "'"$GATEWAY"'"
}'