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
34972630
Unverified
Commit
34972630
authored
Apr 20, 2021
by
AristoChen
Browse files
Allow user to specify DNS
parent
cc3f75d9
Changes
1
Show whitespace changes
Inline
Side-by-side
debian-config-functions-network
View file @
34972630
...
...
@@ -227,12 +227,13 @@ function create_if_config() {
address
=
$(
ip
-4
addr show dev
$1
|
awk
'/inet/ {print $2}'
|
cut
-d
'/'
-f1
)
netmask
=
$(
ip
-4
addr show dev
$1
|
awk
'/inet/ {print $2}'
|
cut
-d
'/'
-f2
)
gateway
=
$(
route
-n
|
grep
'UG[ \t]'
|
awk
'{print $2}'
|
sed
-n
'1p'
)
dns
=
$gateway
echo
-e
"# armbian-config created"
echo
-e
"source /etc/network/interfaces.d/*
\n
"
if
[[
"
$3
"
==
"fixed"
]]
;
then
echo
-e
"# Local loopback
\n
auto lo
\n
iface lo init loopback
\n
"
echo
-e
"# Interface
$2
\n
auto
$2
\n
allow-hotplug
$2
"
echo
-e
"iface
$2
inet static
\n\t
address
$address
\n\t
netmask
$netmask
\n\t
gateway
$gateway
\n\t
dns-nameservers
8.8.8.8
"
echo
-e
"iface
$2
inet static
\n\t
address
$address
\n\t
netmask
$netmask
\n\t
gateway
$gateway
\n\t
dns-nameservers
$dns
"
fi
}
...
...
@@ -360,7 +361,7 @@ function nm_ip_editor ()
"Gateway:"
3 1
"
$gateway
"
3 15 15 0
\
"DNS:"
4 1
"
$dns
"
4 15 15 0
\
2>&1 1>&3 |
{
read
-r
address
;
read
-r
netmask
;
read
-r
gateway
;
read
-r
dns
read
-r
address
;
read
-r
netmask
;
read
-r
gateway
;
read
-r
dns
if
[[
$?
=
0
]]
;
then
localuuid
=
$(
LC_ALL
=
C nmcli
-f
UUID,DEVICE connection show |
grep
$1
|
awk
'{print $1}'
)
# convert netmask value to CIDR if required
...
...
@@ -400,18 +401,18 @@ function systemd_ip_editor ()
if
[[
-f
$filename
]]
;
then
sed
-i
'/Network/,$d'
$filename
exec
3>&1
dialog
--title
" Static IP configuration"
--backtitle
"
$BACKTITLE
"
--form
"
\n
Adapter:
$1
\n
"
12 38 0
\
dialog
--title
" Static IP configuration"
--backtitle
"
$BACKTITLE
"
--form
"
\n
Adapter:
$1
\n
"
13 38 0
\
"Address:"
1 1
"
$address
"
1 15 15 0
\
"Netmask:"
2 1
"
$netmask
"
2 15 15 0
\
"Gateway:"
3 1
"
$gateway
"
3 15 15 0
\
"DNS:"
4 1
"
$dns
"
4 15 15 0
\
2>&1 1>&3 |
{
read
-r
address
;
read
-r
netmask
;
read
-r
gateway
read
-r
address
;
read
-r
netmask
;
read
-r
gateway
;
read
-r
dns
;
if
[[
$?
=
0
]]
;
then
echo
-e
"[Network]"
>>
$filename
echo
-e
"Address=
$address
"
>>
$filename
echo
-e
"Gateway=
$gateway
"
>>
$filename
echo
-e
"DNS=
8.8.8.8
"
>>
$filename
echo
-e
"DNS=
$dns
"
>>
$filename
fi
}
fi
...
...
@@ -428,18 +429,18 @@ function ip_editor ()
{
exec
3>&1
dialog
--title
" Static IP configuration"
--backtitle
"
$BACKTITLE
"
--form
"
\n
Adapter:
$1
\n
"
12 38 0
\
dialog
--title
" Static IP configuration"
--backtitle
"
$BACKTITLE
"
--form
"
\n
Adapter:
$1
\n
"
13 38 0
\
"Address:"
1 1
"
$address
"
1 15 15 0
\
"Netmask:"
2 1
"
$netmask
"
2 15 15 0
\
"Gateway:"
3 1
"
$gateway
"
3 15 15 0
\
"DNS:"
4 1
"
$dns
"
4 15 15 0
\
2>&1 1>&3 |
{
read
-r
address
;
read
-r
netmask
;
read
-r
gateway
read
-r
address
;
read
-r
netmask
;
read
-r
gateway
;
read
-r
dns
;
if
[[
$?
=
0
]]
;
then
echo
-e
"# armbian-config created
\n
source /etc/network/interfaces.d/*
\n
"
>
$3
echo
-e
"# Local loopback
\n
auto lo
\n
iface lo inet loopback
\n
"
>>
$3
echo
-e
"# Interface
$2
\n
auto
$2
\n
allow-hotplug
$2
\n
iface
$2
inet static
\
\n\t
address
$address
\n\t
netmask
$netmask
\n\t
gateway
$gateway
\n\t
dns-nameservers
8.8.8.8
"
>>
$3
\n\t
address
$address
\n\t
netmask
$netmask
\n\t
gateway
$gateway
\n\t
dns-nameservers
$dns
"
>>
$3
fi
}
...
...
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