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

Allow user to specify DNS

parent cc3f75d9
...@@ -227,12 +227,13 @@ function create_if_config() { ...@@ -227,12 +227,13 @@ function create_if_config() {
address=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f1) 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) 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') gateway=$(route -n | grep 'UG[ \t]' | awk '{print $2}' | sed -n '1p')
dns=$gateway
echo -e "# armbian-config created" echo -e "# armbian-config created"
echo -e "source /etc/network/interfaces.d/*\n" echo -e "source /etc/network/interfaces.d/*\n"
if [[ "$3" == "fixed" ]]; then if [[ "$3" == "fixed" ]]; then
echo -e "# Local loopback\nauto lo\niface lo init loopback\n" echo -e "# Local loopback\nauto lo\niface lo init loopback\n"
echo -e "# Interface $2\nauto $2\nallow-hotplug $2" echo -e "# Interface $2\nauto $2\nallow-hotplug $2"
echo -e "iface $2 inet static\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8" echo -e "iface $2 inet static\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers $dns"
fi fi
} }
...@@ -360,7 +361,7 @@ function nm_ip_editor () ...@@ -360,7 +361,7 @@ function nm_ip_editor ()
"Gateway:" 3 1 "$gateway" 3 15 15 0 \ "Gateway:" 3 1 "$gateway" 3 15 15 0 \
"DNS:" 4 1 "$dns" 4 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 dns 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
...@@ -398,22 +399,22 @@ function systemd_ip_editor () ...@@ -398,22 +399,22 @@ function systemd_ip_editor ()
local filename="/etc/systemd/network/10-$1.network" local filename="/etc/systemd/network/10-$1.network"
if [[ -f $filename ]]; then if [[ -f $filename ]]; then
sed -i '/Network/,$d' $filename sed -i '/Network/,$d' $filename
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
echo -e "[Network]" >>$filename echo -e "[Network]" >>$filename
echo -e "Address=$address" >> $filename echo -e "Address=$address" >> $filename
echo -e "Gateway=$gateway" >> $filename echo -e "Gateway=$gateway" >> $filename
echo -e "DNS=8.8.8.8" >> $filename echo -e "DNS=$dns" >> $filename
fi fi
} }
fi fi
} }
...@@ -428,20 +429,20 @@ function ip_editor () ...@@ -428,20 +429,20 @@ function ip_editor ()
{ {
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
echo -e "# armbian-config created\nsource /etc/network/interfaces.d/*\n" >$3 echo -e "# armbian-config created\nsource /etc/network/interfaces.d/*\n" >$3
echo -e "# Local loopback\nauto lo\niface lo inet loopback\n" >> $3 echo -e "# Local loopback\nauto lo\niface lo inet loopback\n" >> $3
echo -e "# Interface $2\nauto $2\nallow-hotplug $2\niface $2 inet static\ echo -e "# Interface $2\nauto $2\nallow-hotplug $2\niface $2 inet static\
\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8" >> $3 \n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers $dns" >> $3
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