mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
core: 通过默认网关找到网卡
This commit is contained in:
parent
fc56ddd7fa
commit
ff57f6a136
12
reinstall.sh
12
reinstall.sh
@ -848,10 +848,18 @@ collect_netconf() {
|
||||
|
||||
# 部分机器精简了 powershell
|
||||
# 所以不要用 powershell 获取网络信息
|
||||
ids=$(wmic nic where "PhysicalAdapter=true and MACAddress is not null and (PNPDeviceID like '%VEN_%&DEV_%' or PNPDeviceID like '%{F8615163-DF3E-46C5-913F-F2D2F965ED0E}%')" get InterfaceIndex | del_cr | sed '1d')
|
||||
# ids=$(wmic nic where "PhysicalAdapter=true and MACAddress is not null and (PNPDeviceID like '%VEN_%&DEV_%' or PNPDeviceID like '%{F8615163-DF3E-46C5-913F-F2D2F965ED0E}%')" get InterfaceIndex | del_cr | sed '1d')
|
||||
|
||||
# 否 手动 0 0.0.0.0/0 19 192.168.1.1
|
||||
# 否 手动 0 0.0.0.0/0 59 nekoray-tun
|
||||
ids="
|
||||
$(netsh int ipv4 show route | grep --text -F '0.0.0.0/0' | awk '$6 ~ /\./ {print $5}')
|
||||
$(netsh int ipv6 show route | grep --text -F '::/0' | awk '$6 ~ /:/ {print $5}')
|
||||
"
|
||||
ids=$(echo "$ids" | sort -u)
|
||||
for id in $ids; do
|
||||
config=$(wmic nicconfig where "InterfaceIndex='$id'" get MACAddress,IPAddress,IPSubnet,DefaultIPGateway /format:list | del_cr)
|
||||
# 排除 IP/子网/网关为空的
|
||||
# 排除 IP/子网/网关/MAC 为空的
|
||||
if grep -q '=$' <<<"$config"; then
|
||||
continue
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user