mirror of
https://github.com/thelittlerocket/pve.git
synced 2024-11-15 19:44:38 +08:00
Update network.sh
This commit is contained in:
parent
58bd060078
commit
c402648e62
1 changed files with 1 additions and 11 deletions
12
network.sh
12
network.sh
|
@ -6,17 +6,7 @@ BRIDGE_NAME="vmbr0"
|
||||||
|
|
||||||
# 获取本地IPv4地址和子网掩码
|
# 获取本地IPv4地址和子网掩码
|
||||||
IP_ADDR=$(ip route get 8.8.8.8 | head -1 | awk '{print $7}')
|
IP_ADDR=$(ip route get 8.8.8.8 | head -1 | awk '{print $7}')
|
||||||
SUBNET_MASK=$(ip route get 8.8.8.8 | head -1 | awk '{print $1}' | awk -F"/" '{print $2}')
|
SUBNET_MASK="255.255.255.0"
|
||||||
|
|
||||||
# 计算网络地址
|
|
||||||
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]}))."
|
|
||||||
done
|
|
||||||
NET_ADDR=${NET_ADDR::-1}
|
|
||||||
|
|
||||||
# 获取网关地址
|
# 获取网关地址
|
||||||
GATEWAY=$(ip route | awk '/default/ {print $3}')
|
GATEWAY=$(ip route | awk '/default/ {print $3}')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue