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
cc3f75d9
Unverified
Commit
cc3f75d9
authored
Apr 20, 2021
by
AristoChen
Browse files
Allow user to specify DNS when setting static IP
parent
5859618e
Changes
1
Hide whitespace changes
Inline
Side-by-side
debian-config-functions-network
View file @
cc3f75d9
...
...
@@ -351,15 +351,16 @@ function netmask_to_cidr ()
#
function
nm_ip_editor
()
{
dns
=
$gateway
exec
3>&1
dialog
--title
" Static IP configuration"
--backtitle
"
$BACKTITLE
"
--form
"
\n
Adapter:
$1
\n
"
12 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
\
exec
3>&1
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
localuuid
=
$(
LC_ALL
=
C nmcli
-f
UUID,DEVICE connection show |
grep
$1
|
awk
'{print $1}'
)
# convert netmask value to CIDR if required
...
...
@@ -372,14 +373,14 @@ exec 3>&1
# adjust existing
nmcli con mod
$localuuid
ipv4.method manual ipv4.addresses
"
$address
/
$CIDR
"
>
/dev/null 2>&1
nmcli con mod
$localuuid
ipv4.method manual ipv4.gateway
"
$gateway
"
>
/dev/null 2>&1
nmcli con mod
$localuuid
ipv4.dns
"
8.8.8.8
,
$gateway
"
>
/dev/null 2>&1
nmcli con mod
$localuuid
ipv4.dns
"
$dns
,
$gateway
"
>
/dev/null 2>&1
nmcli con down
$localuuid
>
/dev/null 2>&1
sleep
2
nmcli con up
$localuuid
>
/dev/null 2>&1
else
# create new
nmcli con add con-name
"armbian"
ifname
"
$1
"
type
802-3-ethernet ip4
"
$address
/
$CIDR
"
gw4
"
$gateway
"
>
/dev/null 2>&1
nmcli con mod
"armbian"
ipv4.dns
"
8.8.8.8
,
$gateway
"
>
/dev/null 2>&1
nmcli con mod
"armbian"
ipv4.dns
"
$dns
,
$gateway
"
>
/dev/null 2>&1
nmcli con up
"armbian"
>
/dev/null 2>&1
fi
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