Skip to content

Commit

Permalink
v7.9
Browse files Browse the repository at this point in the history
+ DietPi-Config | Only use /etc/network/interfaces for static DNS server info when the dns-nameservers setting is actually in use (uncommented), else fallback to /etc/resolv.conf which is definittly the affectively applied system DNS server, while we do not know whether it has been applied statically or via DHCP or dynamically via resolvconf. Fix mawk syntax for this. Furthermore, to avoid confusion, on first boot adjust the dns-nameservers entry even if resolvconf is not available (commented of course) so that it matches /etc/resolv.conf in any case.
  • Loading branch information
MichaIng committed Dec 11, 2021
1 parent 60112cb commit b9943d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dietpi/dietpi-config
Original file line number Diff line number Diff line change
Expand Up @@ -2417,8 +2417,8 @@ NB: All Ethernet connections will be dropped!' && Network_ApplyChanges
ETH_IP_STATIC=$(mawk '$1=="address"{print $2;exit}' /etc/network/interfaces)
ETH_GATEWAY_STATIC=$(mawk '$1=="gateway"{print $2;exit}' /etc/network/interfaces)
ETH_MASK_STATIC=$(mawk '$1=="netmask"{print $2;exit}' /etc/network/interfaces)
ETH_DNS_STATIC=$(mawk '$1~/#?dns-nameservers/{print $2,$3;exit}' /etc/network/interfaces)
[[ $ETH_DNS_STATIC ]] || ETH_DNS_STATIC=$(mawk '$1="nameserver"{print $2;exit}' /etc/resolv.conf)
ETH_DNS_STATIC=$(mawk '$1=="dns-nameservers"{print $2,$3;exit}' /etc/network/interfaces)
[[ $ETH_DNS_STATIC ]] || ETH_DNS_STATIC=$(mawk '$1=="nameserver"{print $2;exit}' /etc/resolv.conf)
# Remove trailing space in case of single nameserver, due to mawk '{print $2,$3}'
ETH_DNS_STATIC=${ETH_DNS_STATIC%[[:blank:]]}
ETH_DEV_IFACE=$(G_GET_NET -q -t eth iface) || ETH_DEV_IFACE='eth0'
Expand All @@ -2434,8 +2434,8 @@ NB: All Ethernet connections will be dropped!' && Network_ApplyChanges
WIFI_IP_STATIC=$(mawk '$1=="address"{print $2}' /etc/network/interfaces | mawk 'NR==2')
WIFI_GATEWAY_STATIC=$(mawk '$1=="gateway"{print $2}' /etc/network/interfaces | mawk 'NR==2')
WIFI_MASK_STATIC=$(mawk '$1=="netmask"{print $2}' /etc/network/interfaces | mawk 'NR==2')
WIFI_DNS_STATIC=$(mawk '$1~/#?dns-nameservers/{print $2,$3}' /etc/network/interfaces | mawk 'NR==2')
[[ $WIFI_DNS_STATIC ]] || WIFI_DNS_STATIC=$(mawk '$1="nameserver"{print $2;exit}' /etc/resolv.conf)
WIFI_DNS_STATIC=$(mawk '$1=="dns-nameservers"{print $2,$3}' /etc/network/interfaces | mawk 'NR==2')
[[ $WIFI_DNS_STATIC ]] || WIFI_DNS_STATIC=$(mawk '$1=="nameserver"{print $2;exit}' /etc/resolv.conf)
# Remove trailing space in case of single nameserver, due to mawk '{print $2,$3}'
WIFI_DNS_STATIC=${WIFI_DNS_STATIC%[[:blank:]]}
WIFI_DEV_IFACE=$(G_GET_NET -q -t wlan iface) || WIFI_DEV_IFACE='wlan0'
Expand Down
1 change: 1 addition & 0 deletions rootfs/var/lib/dietpi/services/dietpi-firstboot.bash
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ _EOF_

> /etc/resolv.conf
for i in $static_dns; do echo "nameserver $i" >> /etc/resolv.conf; done
sed -i "/dns-nameservers/c\#dns-nameservers $static_dns" /etc/network/interfaces

fi

Expand Down

0 comments on commit b9943d3

Please sign in to comment.