[17/29] dhcpcd.exe: Use DNS servers from QMI

Message ID 20221201172318.3166615-17-michael.tremer@ipfire.org
State Accepted
Commit ccf36e9e8c1361b8addf1508444276e79310afe0
Headers
Series [01/29] libgudev: New package |

Commit Message

Michael Tremer Dec. 1, 2022, 5:23 p.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/networking/dhcpcd.exe | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
  

Patch

diff --git a/src/initscripts/networking/dhcpcd.exe b/src/initscripts/networking/dhcpcd.exe
index fe64132c8..acd083b6f 100644
--- a/src/initscripts/networking/dhcpcd.exe
+++ b/src/initscripts/networking/dhcpcd.exe
@@ -111,6 +111,8 @@  setup_qmi() {
 	local netmask
 	local gateway
 	local mtu=1500
+	local dns1
+	local dns2
 
 	local line
 	while read -r line; do
@@ -127,6 +129,12 @@  setup_qmi() {
 			*IPv4\ gateway\ address:*)
 				gateway="${value}"
 				;;
+			*IPv4\ primary\ DNS:*)
+				dns1="${value}"
+				;;
+			*IPv4\ secondary\ DNS:*)
+				dns2="${value}"
+				;;
 			*MTU:*)
 				mtu="${value}"
 				;;
@@ -154,6 +162,14 @@  setup_qmi() {
 		ip route add default via "${gateway}" mtu "${mtu}"
 	fi
 
+	# Store and DNS servers
+	if [ -n "${dns1}" ]; then
+		echo -n "${dns1}" > /var/ipfire/red/dns1
+	fi
+	if [ -n "${dns2}" ]; then
+		echo n "${dns2}"  > /var/ipfire/red/dns2
+	fi
+
 	return 0
 }