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"
NET_ADDR=""
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
NET_ADDR=${NET_ADDR::-1}
@ -22,8 +22,13 @@ GATEWAY=$(ip route | awk '/default/ {print $3}')
# 创建虚拟网桥并将其记录到PVE配置中
pvesh set /nodes/localhost/network/$BRIDGE_NAME \
bridge_ports=none \
bridge_vlan_aware=1 \
vlan_ids=100 \
addresses="$IP_ADDR/$SUBNET_MASK" \
gateway="$GATEWAY"
-content-type "application/json" \
-put \
-data \
'{
"bridge_ports": "none",
"bridge_vlan_aware": "1",
"vlan_ids": "100",
"addresses": "'"$IP_ADDR/$SUBNET_MASK"'",
"gateway": "'"$GATEWAY"'"
}'