diff --git a/profile_translator_blocklist/templates/CMakeLists.txt.j2 b/profile_translator_blocklist/templates/CMakeLists.txt.j2
index 892e6dfecdba9831097cd0be64a615d3c28e14a7..c524866d7481f82d2c1f49fe908212dc21794a49 100644
--- a/profile_translator_blocklist/templates/CMakeLists.txt.j2
+++ b/profile_translator_blocklist/templates/CMakeLists.txt.j2
@@ -10,6 +10,10 @@ IF( OPENWRT_CROSSCOMPILING )
 target_link_libraries({{nfqueue_name}} jansson mnl nfnetlink nftnl nftables netfilter_queue netfilter_log)
 ENDIF()
 target_link_libraries({{nfqueue_name}} nfqueue packet_utils rule_utils)
-target_link_libraries({{nfqueue_name}} header {{custom_parsers}})
+{% if domain_names|length > 0 %}
+target_link_libraries({{nfqueue_name}} header dns dns_map)
+{% endif %}
+{% set parsers = custom_parsers - set(["dns"]) if "dns" in custom_parsers else custom_parsers %}
+target_link_libraries({{nfqueue_name}} header {{parsers}})
 target_include_directories({{nfqueue_name}} PRIVATE ${INCLUDE_DIR} ${INCLUDE_PARSERS_DIR})
 install(TARGETS {{nfqueue_name}} DESTINATION ${EXECUTABLE_OUTPUT_PATH})
diff --git a/profile_translator_blocklist/templates/header.c.j2 b/profile_translator_blocklist/templates/header.c.j2
index 8693f2916d5267448f1001fa9d73f35551b1d2f3..eeb32fdbde827b9462542ad2842b52303fe495d4 100644
--- a/profile_translator_blocklist/templates/header.c.j2
+++ b/profile_translator_blocklist/templates/header.c.j2
@@ -26,12 +26,14 @@
 {% if "dns" in parser %}
 {% set dns_parser_included.value = True %}
 #include "dns.h"
+#include "dns_map.h"
 {% else %}
 #include "{{parser}}.h"
 {% endif %}
 {% endfor %}
 {% if domain_names|length > 0 and not dns_parser_included.value %}
 #include "dns.h"
+#include "dns_map.h"
 {% endif %}
 
 
diff --git a/profile_translator_blocklist/translator.py b/profile_translator_blocklist/translator.py
index a0c61149d633a808eeff71b3b589a3982123985e..c69aa89cb2fefe8397dfddd5c40c23e668101da8 100644
--- a/profile_translator_blocklist/translator.py
+++ b/profile_translator_blocklist/translator.py
@@ -233,7 +233,8 @@ def write_firewall(
         cmake_dict = {
             "device":  device["name"],
             "nfqueue_name": nfqueue_name,
-            "custom_parsers": custom_parsers
+            "custom_parsers": custom_parsers,
+            "domain_names": global_accs["domain_names"]
         }
         env.get_template("CMakeLists.txt.j2").stream(cmake_dict).dump(os.path.join(output_dir, "CMakeLists.txt"))