Unverified Commit cc3f75d9 authored by AristoChen's avatar AristoChen
Browse files

Allow user to specify DNS when setting static IP

parent 5859618e
...@@ -351,15 +351,16 @@ function netmask_to_cidr () ...@@ -351,15 +351,16 @@ function netmask_to_cidr ()
# #
function nm_ip_editor () function nm_ip_editor ()
{ {
dns=$gateway
exec 3>&1 exec 3>&1
dialog --title " Static IP configuration" --backtitle "$BACKTITLE" --form "\nAdapter: $1 dialog --title " Static IP configuration" --backtitle "$BACKTITLE" --form "\nAdapter: $1 \n " 13 38 0 \
\n " 12 38 0 \
"Address:" 1 1 "$address" 1 15 15 0 \ "Address:" 1 1 "$address" 1 15 15 0 \
"Netmask:" 2 1 "$netmask" 2 15 15 0 \ "Netmask:" 2 1 "$netmask" 2 15 15 0 \
"Gateway:" 3 1 "$gateway" 3 15 15 0 \ "Gateway:" 3 1 "$gateway" 3 15 15 0 \
"DNS:" 4 1 "$dns" 4 15 15 0 \
2>&1 1>&3 | { 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 if [[ $? = 0 ]]; then
localuuid=$(LC_ALL=C nmcli -f UUID,DEVICE connection show | grep $1 | awk '{print $1}') localuuid=$(LC_ALL=C nmcli -f UUID,DEVICE connection show | grep $1 | awk '{print $1}')
# convert netmask value to CIDR if required # convert netmask value to CIDR if required
...@@ -372,14 +373,14 @@ exec 3>&1 ...@@ -372,14 +373,14 @@ exec 3>&1
# adjust existing # 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.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.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 nmcli con down $localuuid >/dev/null 2>&1
sleep 2 sleep 2
nmcli con up $localuuid >/dev/null 2>&1 nmcli con up $localuuid >/dev/null 2>&1
else else
# create new # 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 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 nmcli con up "armbian" >/dev/null 2>&1
fi fi
fi fi
......
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