1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-13 02:51:50 +00:00

Use traceroute to get gateway in final case

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-10-21 22:29:53 +02:00
parent eb5f7c03e9
commit 85ba3b7c19

View file

@ -128,6 +128,9 @@ interface_multipath_settings() {
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -l 1 -e '@.route[@.target="0.0.0.0"].nexthop' | tr -d "\n")
fi
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(traceroute -m1 -i $iface 8.8.8.8 2>/dev/null | awk 'FNR==2{ print $2 }')
fi
network_get_subnet netmask $config
[ -n "$netmask" ] && [ "$(echo $netmask | grep '/')" != "" ] && netmask=""
[ -z "$netmask" ] && netmask=$(ip -4 addr show dev $iface | grep peer | awk '{print $4}' | cut -d/ -f2 | tr -d "\n")