[lxc-devel] [lxc/master] /etc/resolv.conf grows indefinitely
Rachid-Koucha on Github
lxc-bot at linuxcontainers.org
Sun Jan 27 12:47:05 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 566 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190127/4b80e618/attachment.bin>
-------------- next part --------------
From 567f8915962316dfee3b040bad404da7cdcbbe38 Mon Sep 17 00:00:00 2001
From: Rachid Koucha <47061324+Rachid-Koucha at users.noreply.github.com>
Date: Sun, 27 Jan 2019 13:46:48 +0100
Subject: [PATCH] /etc/resolv.conf grows indefinitely
This file grows indefinitely : upon each DHCP lease renew,
the "nameserver ..dns..." line is added at the end of the file.
Make a "grep" in the file to make sure that the same line
does not already exist.
Signed-off-by: Rachid Koucha <rachid.koucha at gmail.com>
---
templates/lxc-busybox.in | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
index 2171e2d597..3782687a54 100644
--- a/templates/lxc-busybox.in
+++ b/templates/lxc-busybox.in
@@ -164,7 +164,10 @@ case "\$1" in
[ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
for i in \$dns ; do
- echo nameserver \$i >> /etc/resolv.conf
+ grep "nameserver \$i" /etc/resolv.conf > /dev/null 2>&1
+ if [ \$? -ne 0 ]; then
+ echo nameserver \$i >> /etc/resolv.conf
+ fi
done
;;
esac
More information about the lxc-devel
mailing list