Commit 1fd13c25 authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

More metric fixes, changes are now saved, changing the way dnsmas is loaded

parent 579c941e
......@@ -555,7 +555,7 @@ function select_default_interface ()
else
IFS=$'\r\n'
GLOBIGNORE='*'
local ADAPTER=($(ls /sys/class/net | grep -E -v 'lo|tun|bonding_masters|dummy0|bond0|sit0|br0'))
local ADAPTER=($(nmcli -t -f DEVICE connection show --active))
local LIST=()
for i in "${ADAPTER[@]}"
do
......@@ -573,35 +573,53 @@ function select_default_interface ()
else
exec 3>&1
DEFAULT_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select default interface" --clear --menu "" $((6+${LIST_LENGTH})) 0 15 "${LIST[@]}" 2>&1 1>&3)
--title "Select default interface" --clear --menu "" $((6+${LIST_LENGTH})) 74 14 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
fi
# set highest metric to default adaptor
HIGHEST_METRIC=$(nmcli -t -f UUID,TYPE,DEVICE connection show --active | grep $DEFAULT_ADAPTER | sed 's/:.*$//')
METRIC=100
# set metric to 100
nmcli connection modify $HIGHEST_METRIC ipv4.route-metric $METRIC
# set metric to 50
nmcli connection modify $HIGHEST_METRIC ipv4.route-metric 50 2> /dev/null
METRIC=77
# set others wired
REMAINING=( `nmcli -t -f UUID,TYPE,DEVICE connection show --active | grep ethernet | grep -v $DEFAULT_ADAPTER | sed 's/:.*$//'` )
for i in "${REMAINING[@]}"
do
METRIC=$(( $METRIC + 1 ))
nmcli connection modify ${i} ipv4.route-metric $METRIC
done
if [[ ${#REMAINING[@]} -ge 1 ]]; then
for i in "${REMAINING[@]}"
do
METRIC=$(( $METRIC + 1 ))
nmcli connection modify ${i} ipv4.route-metric $METRIC
done
fi
# set other wireless
METRIC=1000
METRIC=88
REMAINING=( `nmcli -t -f UUID,TYPE,DEVICE connection show --active | grep wireless | grep -v $DEFAULT_ADAPTER | sed 's/:.*$//'` )
for i in "${REMAINING[@]}"
do
METRIC=$(( $METRIC + 1 ))
nmcli connection modify ${i} ipv4.route-metric $METRIC
done
if [[ ${#REMAINING[@]} -ge 1 ]]; then
for i in "${REMAINING[@]}"
do
METRIC=$(( $METRIC + 1 ))
nmcli connection modify ${i} ipv4.route-metric $METRIC
done
fi
# create default metrics file
cat <<-EOF > /etc/NetworkManager/conf.d/armbian-default-metric.conf
[connection-ethernet-gateway]
match-device=interface-name:$DEFAULT_ADAPTER
ipv4.route-metric=50
[connection-wifi-other]
match-device=type:wifi
ipv4.route-metric=88
[connection-ethernet-other]
match-device=type:ethernet
ipv4.route-metric=77
EOF
}
......
......@@ -361,6 +361,7 @@ function jobs ()
rm -f /etc/network/interfaces.d/armbian.ap.nat
rm -f /etc/network/interfaces.d/armbian.ap.bridge
rm -f /etc/dnsmasq.conf
iptables -t nat -D POSTROUTING 1
rm -f /etc/iptables.ipv4.nat
rm -f /var/run/hostapd/* >/dev/null 2>&1
reload-nety
......@@ -396,6 +397,7 @@ function jobs ()
rm -f /etc/network/interfaces.d/armbian.ap.nat
rm -f /etc/network/interfaces.d/armbian.ap.bridge
rm -f /etc/dnsmasq.conf
iptables -t nat -D POSTROUTING 1
rm -f /etc/iptables.ipv4.nat
rm -f /var/run/hostapd/* >/dev/null 2>&1
sed -i '/^iptables/ d' /etc/rc.local
......@@ -536,6 +538,7 @@ function jobs ()
echo -e "# armbian NAT hostapd\nallow-hotplug $WIRELESS_ADAPTER\niface $WIRELESS_ADAPTER inet static " > $TEMP_CONF
echo -e "\taddress 172.24.1.1\n\tnetmask 255.255.255.0\n\tnetwork 172.24.1.0\n\tbroadcast 172.24.1.255" >> $TEMP_CONF
echo -e "\tpost-up service dnsmasq start\tpost-up \n\tiptables-restore < /etc/iptables.ipv4.nat\n\tpost-down service dnsmasq stop" >> $TEMP_CONF
# create new configuration
echo "interface=$WIRELESS_ADAPTER # Use interface $WIRELESS_ADAPTER" > /etc/dnsmasq.conf
echo "listen-address=172.24.1.1 # Explicitly specify the address to listen on" >> /etc/dnsmasq.conf
......@@ -557,11 +560,11 @@ function jobs ()
# - Save IP tables, applied during ifup in /etc/network/interfaces.
iptables-save > /etc/iptables.ipv4.nat
sed -i 's/^bridge=.*/#&/' /etc/hostapd.conf
sed -e 's/exit 0//g' -i /etc/rc.local
#sed -e 's/exit 0//g' -i /etc/rc.local
# workaround if hostapd is too slow
echo "service dnsmasq start" >> /etc/rc.local
echo "iptables-restore < /etc/iptables.ipv4.nat" >> /etc/rc.local
echo "exit 0" >> /etc/rc.local
#echo "service dnsmasq start" >> /etc/rc.local
#echo "iptables-restore < /etc/iptables.ipv4.nat" >> /etc/rc.local
#echo "exit 0" >> /etc/rc.local
;;
3)exit;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment