Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Config
Commits
1fd13c25
Commit
1fd13c25
authored
Apr 23, 2019
by
Igor Pecovnik
Browse files
More metric fixes, changes are now saved, changing the way dnsmas is loaded
parent
579c941e
Changes
2
Show whitespace changes
Inline
Side-by-side
debian-config-functions-network
View file @
1fd13c25
...
@@ -555,7 +555,7 @@ function select_default_interface ()
...
@@ -555,7 +555,7 @@ function select_default_interface ()
else
else
IFS
=
$'
\r\n
'
IFS
=
$'
\r\n
'
GLOBIGNORE
=
'*'
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
=()
local
LIST
=()
for
i
in
"
${
ADAPTER
[@]
}
"
for
i
in
"
${
ADAPTER
[@]
}
"
do
do
...
@@ -573,35 +573,53 @@ function select_default_interface ()
...
@@ -573,35 +573,53 @@ function select_default_interface ()
else
else
exec
3>&1
exec
3>&1
DEFAULT_ADAPTER
=
$(
dialog
--nocancel
--backtitle
"
$BACKTITLE
"
--no-collapse
\
DEFAULT_ADAPTER
=
$(
dialog
--nocancel
--backtitle
"
$BACKTITLE
"
--no-collapse
\
--title
"Select default interface"
--clear
--menu
""
$((
6
+
${
LIST_LENGTH
}))
0
1
5
"
${
LIST
[@]
}
"
2>&1 1>&3
)
--title
"Select default interface"
--clear
--menu
""
$((
6
+
${
LIST_LENGTH
}))
74
1
4
"
${
LIST
[@]
}
"
2>&1 1>&3
)
exec
3>&-
exec
3>&-
fi
fi
fi
fi
# set highest metric to default adaptor
# set highest metric to default adaptor
HIGHEST_METRIC
=
$(
nmcli
-t
-f
UUID,TYPE,DEVICE connection show
--active
|
grep
$DEFAULT_ADAPTER
|
sed
's/:.*$//'
)
HIGHEST_METRIC
=
$(
nmcli
-t
-f
UUID,TYPE,DEVICE connection show
--active
|
grep
$DEFAULT_ADAPTER
|
sed
's/:.*$//'
)
METRIC
=
100
# set metric to
10
0
# set metric to
5
0
nmcli connection modify
$HIGHEST_METRIC
ipv4.route-metric
$METRIC
nmcli connection modify
$HIGHEST_METRIC
ipv4.route-metric
50 2> /dev/null
METRIC
=
77
# set others wired
# set others wired
REMAINING
=(
`
nmcli
-t
-f
UUID,TYPE,DEVICE connection show
--active
|
grep
ethernet |
grep
-v
$DEFAULT_ADAPTER
|
sed
's/:.*$//'
`
)
REMAINING
=(
`
nmcli
-t
-f
UUID,TYPE,DEVICE connection show
--active
|
grep
ethernet |
grep
-v
$DEFAULT_ADAPTER
|
sed
's/:.*$//'
`
)
if
[[
${#
REMAINING
[@]
}
-ge
1
]]
;
then
for
i
in
"
${
REMAINING
[@]
}
"
for
i
in
"
${
REMAINING
[@]
}
"
do
do
METRIC
=
$((
$METRIC
+
1
))
METRIC
=
$((
$METRIC
+
1
))
nmcli connection modify
${
i
}
ipv4.route-metric
$METRIC
nmcli connection modify
${
i
}
ipv4.route-metric
$METRIC
done
done
fi
# set other wireless
# 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/:.*$//'
`
)
REMAINING
=(
`
nmcli
-t
-f
UUID,TYPE,DEVICE connection show
--active
|
grep
wireless |
grep
-v
$DEFAULT_ADAPTER
|
sed
's/:.*$//'
`
)
if
[[
${#
REMAINING
[@]
}
-ge
1
]]
;
then
for
i
in
"
${
REMAINING
[@]
}
"
for
i
in
"
${
REMAINING
[@]
}
"
do
do
METRIC
=
$((
$METRIC
+
1
))
METRIC
=
$((
$METRIC
+
1
))
nmcli connection modify
${
i
}
ipv4.route-metric
$METRIC
nmcli connection modify
${
i
}
ipv4.route-metric
$METRIC
done
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
}
}
...
...
debian-config-jobs
View file @
1fd13c25
...
@@ -361,6 +361,7 @@ function jobs ()
...
@@ -361,6 +361,7 @@ function jobs ()
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/dnsmasq.conf
rm
-f
/etc/dnsmasq.conf
iptables
-t
nat
-D
POSTROUTING 1
rm
-f
/etc/iptables.ipv4.nat
rm
-f
/etc/iptables.ipv4.nat
rm
-f
/var/run/hostapd/
*
>
/dev/null 2>&1
rm
-f
/var/run/hostapd/
*
>
/dev/null 2>&1
reload-nety
reload-nety
...
@@ -396,6 +397,7 @@ function jobs ()
...
@@ -396,6 +397,7 @@ function jobs ()
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.nat
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/network/interfaces.d/armbian.ap.bridge
rm
-f
/etc/dnsmasq.conf
rm
-f
/etc/dnsmasq.conf
iptables
-t
nat
-D
POSTROUTING 1
rm
-f
/etc/iptables.ipv4.nat
rm
-f
/etc/iptables.ipv4.nat
rm
-f
/var/run/hostapd/
*
>
/dev/null 2>&1
rm
-f
/var/run/hostapd/
*
>
/dev/null 2>&1
sed
-i
'/^iptables/ d'
/etc/rc.local
sed
-i
'/^iptables/ d'
/etc/rc.local
...
@@ -536,6 +538,7 @@ function jobs ()
...
@@ -536,6 +538,7 @@ function jobs ()
echo
-e
"# armbian NAT hostapd
\n
allow-hotplug
$WIRELESS_ADAPTER
\n
iface
$WIRELESS_ADAPTER
inet static "
>
$TEMP_CONF
echo
-e
"# armbian NAT hostapd
\n
allow-hotplug
$WIRELESS_ADAPTER
\n
iface
$WIRELESS_ADAPTER
inet static "
>
$TEMP_CONF
echo
-e
"
\t
address 172.24.1.1
\n\t
netmask 255.255.255.0
\n\t
network 172.24.1.0
\n\t
broadcast 172.24.1.255"
>>
$TEMP_CONF
echo
-e
"
\t
address 172.24.1.1
\n\t
netmask 255.255.255.0
\n\t
network 172.24.1.0
\n\t
broadcast 172.24.1.255"
>>
$TEMP_CONF
echo
-e
"
\t
post-up service dnsmasq start
\t
post-up
\n\t
iptables-restore < /etc/iptables.ipv4.nat
\n\t
post-down service dnsmasq stop"
>>
$TEMP_CONF
# create new configuration
# create new configuration
echo
"interface=
$WIRELESS_ADAPTER
# Use interface
$WIRELESS_ADAPTER
"
>
/etc/dnsmasq.conf
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
echo
"listen-address=172.24.1.1 # Explicitly specify the address to listen on"
>>
/etc/dnsmasq.conf
...
@@ -557,11 +560,11 @@ function jobs ()
...
@@ -557,11 +560,11 @@ function jobs ()
# - Save IP tables, applied during ifup in /etc/network/interfaces.
# - Save IP tables, applied during ifup in /etc/network/interfaces.
iptables-save
>
/etc/iptables.ipv4.nat
iptables-save
>
/etc/iptables.ipv4.nat
sed
-i
's/^bridge=.*/#&/'
/etc/hostapd.conf
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
# workaround if hostapd is too slow
echo
"service dnsmasq start"
>>
/etc/rc.local
#
echo "service dnsmasq start" >> /etc/rc.local
echo
"iptables-restore < /etc/iptables.ipv4.nat"
>>
/etc/rc.local
#
echo "iptables-restore < /etc/iptables.ipv4.nat" >> /etc/rc.local
echo
"exit 0"
>>
/etc/rc.local
#
echo "exit 0" >> /etc/rc.local
;;
;;
3
)
exit
;;
3
)
exit
;;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment