ipcalc: utiliser ip route au lieu de route
This commit is contained in:
parent
feb00bcf11
commit
ad19121f6b
|
@ -343,6 +343,13 @@ function __network_fix_confips() {
|
|||
fi
|
||||
fi
|
||||
done
|
||||
if [ -n "$mainiface" ]; then
|
||||
iface="$mainiface"
|
||||
if ! array_contains ifaces "$iface"; then
|
||||
array_add ifaces "$iface"
|
||||
eval "local ${iface}_gateway $network; local -a ${iface}_ipsuffixes"
|
||||
fi
|
||||
fi
|
||||
# puis construire la liste des adresses IP associées à chaque interface
|
||||
for confip in "${__nfc_confips[@]}"; do
|
||||
network_parse_confip "$confip" iface gateway ipsuffixes
|
||||
|
@ -508,7 +515,20 @@ function network_set_confbrs() {
|
|||
function __network_set_gateway() {
|
||||
# initialiser la variable gateway avec la passerelle associée à l'interface
|
||||
# $1
|
||||
gateway="$(route -n | awk -v iface="$1" '$1 == "0.0.0.0" && $8 == iface { print $2 }')"
|
||||
gateway="$(ip route | awk -v iface="$1" '$1 == "default" {
|
||||
via = ""
|
||||
dev = ""
|
||||
for (i = 2; i <= NF; i++) {
|
||||
if ($i == "via") via = $(i+1)
|
||||
else if ($i == "dev") dev = $(i+1)
|
||||
if (via != "" && dev != "") break
|
||||
}
|
||||
if (dev == iface && via != "") {
|
||||
print via
|
||||
}
|
||||
}')"
|
||||
# le code précédent utilisait route, mais ce n'est pas toujours disponible
|
||||
#gateway="$(route -n | awk -v iface="$1" '$1 == "0.0.0.0" && $8 == iface { print $2 }')"
|
||||
}
|
||||
function __network_set_confip() {
|
||||
# initialiser la variable confip avec l'état de l'interface $1, en assumant
|
||||
|
|
Loading…
Reference in New Issue