diff --git a/roles/dnsmasq/tasks/main.yml b/roles/dnsmasq/tasks/main.yml
index df5e59a0036fffdf778f7004aa573fb48e5caf79..b9f8341a6a63c89131ffd5c7f62cf96f99a00cd0 100644
--- a/roles/dnsmasq/tasks/main.yml
+++ b/roles/dnsmasq/tasks/main.yml
@@ -76,7 +76,7 @@
     line: nameserver {{ hostvars[item]['ansible_default_ipv4']['address'] }}
     dest: "{{resolvconffile}}"
     state: present
-    insertafter: EOF
+    insertafter: "^search.*$"
     backup: yes
     follow: yes
   with_items: groups['kube-master']