免费DNS查询(dns.google)
中级
这是一个DevOps领域的自动化工作流,包含 12 个节点。主要使用 If, Set, Code, SplitOut, FormTrigger 等节点。 使用Google免费公共DNS服务执行多类型DNS查询
前置要求
- •可能需要目标 API 的认证凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "BXm0BiyrBflaibCy",
"meta": {
"instanceId": "5b61629a145a38a93588ff78addb36f97647fd75c5392fcb856e858941f87d19"
},
"name": "免费 DNS 查询 (dns.google)",
"tags": [],
"nodes": [
{
"id": "4340255d-eab4-43f8-a081-c81eb61f4e2b",
"name": "拆分输出",
"type": "n8n-nodes-base.splitOut",
"position": [
928,
656
],
"parameters": {
"include": "allOtherFields",
"options": {},
"fieldToSplitOut": "Types"
},
"typeVersion": 1
},
{
"id": "216ec461-7be9-423c-8898-467ca3435306",
"name": "DNS 查询",
"type": "n8n-nodes-base.httpRequest",
"position": [
1312,
672
],
"parameters": {
"url": "https://dns.google/resolve",
"options": {},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "name",
"value": "={{ $json.Domain }}"
},
{
"name": "type",
"value": "={{ $json.Types }}"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "a1a9cb2e-55b0-4de3-b4dd-481960fdf74f",
"name": "在输出中设置人类可读类型",
"type": "n8n-nodes-base.code",
"position": [
1520,
672
],
"parameters": {
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.type_hr = $('For each DNS type').first().json.Types;\n}\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "7e513dfd-7487-4018-9156-d0a64f65a5e6",
"name": "聚合结果",
"type": "n8n-nodes-base.code",
"position": [
1440,
320
],
"parameters": {
"jsCode": "// Initialize variables to aggregate data across all input items\nlet domain = null;\nconst records = [];\n\n// Loop over input items to process and aggregate the data\nfor (const item of $input.all()) {\n const itemJson = item.json;\n\n // 1. Get the domain name from the first item's Question array\n // Check if domain is not yet set and Question array exists\n if (domain === null && itemJson.Question && itemJson.Question.length > 0) {\n // Extract domain and remove the trailing dot if present\n domain = itemJson.Question[0].name.replace(/\\.$/, '');\n }\n\n // Get the human-readable type from the current item\n // Fallback to a placeholder if 'type_hr' is missing\n const recordType = itemJson.type_hr || 'UNKNOWN';\n\n // 2. Process all answers or insert \"NO ANSWER\" placeholder\n const answerRecords = itemJson.Answer;\n\n if (answerRecords && answerRecords.length > 0) {\n // SUCCESS: Loop over existing answer records\n for (const record of answerRecords) {\n // Add the new record object using the top-level type_hr\n records.push({\n type: recordType,\n data: record.data\n });\n }\n } else {\n // FAILURE: Insert \"NO ANSWER\" placeholder for the current type\n records.push({\n type: recordType,\n data: \"NO ANSWER\"\n });\n }\n}\n\n// 3. Construct the final output object in the desired n8n format\n\n// Create a new item that contains the aggregated data\nconst outputItem = {\n json: {\n domain: domain,\n records: records\n }\n};\n\n// Return a new array containing only the single aggregated output item\nreturn [outputItem];"
},
"typeVersion": 2
},
{
"id": "f1703e6f-9e88-4f65-af93-a42d5f94e3ff",
"name": "默认为所有 DNS 类型",
"type": "n8n-nodes-base.set",
"position": [
736,
576
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"Domain\": \"{{ $json.Domain }}\",\n \"Types\": [\"A\",\"CNAME\",\"AAAA\",\"MX\",\"TXT\",\"NS\"]\n}\n"
},
"typeVersion": 3.4
},
{
"id": "8b95a121-bb65-4a92-8f7d-12ae75e44209",
"name": "使用选定的 DNS 类型",
"type": "n8n-nodes-base.set",
"position": [
736,
752
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={\n \"Domain\": \"{{ $json.Domain }}\",\n \"Types\": {{ $json[\"Types (leave empty to use all)\"] }}\n}\n"
},
"typeVersion": 3.4
},
{
"id": "3f01a762-2608-49c0-bb3a-e37c72405e86",
"name": "如果输入中没有 DNS 类型",
"type": "n8n-nodes-base.if",
"position": [
560,
656
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "69423fc7-bf38-4c05-8172-71c6155f550e",
"operator": {
"type": "array",
"operation": "empty",
"singleValue": true
},
"leftValue": "={{ $json[\"Types (leave empty to use all)\"] }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "49a5b001-6bc4-46c6-aea2-9ee9d72ee147",
"name": "对于每个 DNS 类型",
"type": "n8n-nodes-base.splitInBatches",
"position": [
1104,
656
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "24035b9b-a88a-42d2-98ba-115a6c76ccd2",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1296,
144
],
"parameters": {
"width": 416,
"height": 368,
"content": "## 输出 DNS 查询结果的聚合列表"
},
"typeVersion": 1
},
{
"id": "d4a8faa0-9cae-40fa-bbf2-76cc88ddebc7",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
528
],
"parameters": {
"color": 6,
"width": 1472,
"height": 416,
"content": "## 循环遍历每个类型并执行 DNS 查询"
},
"typeVersion": 1
},
{
"id": "b0696455-1381-4af8-a709-a3643a4a077f",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
144
],
"parameters": {
"color": 5,
"width": 1040,
"height": 368,
"content": "## 信息"
},
"typeVersion": 1
},
{
"id": "2cbf850c-81dd-49f5-906c-39843df897e6",
"name": "表单输入",
"type": "n8n-nodes-base.formTrigger",
"position": [
352,
656
],
"webhookId": "5ba5cd47-8292-4824-b079-c4ae1a9d1d19",
"parameters": {
"options": {},
"formTitle": "DNS lookup",
"formFields": {
"values": [
{
"fieldLabel": "Domain",
"placeholder": "domain.tld",
"requiredField": true
},
{
"fieldType": "checkbox",
"fieldLabel": "Types (leave empty to use all)",
"fieldOptions": {
"values": [
{
"option": "A"
},
{
"option": "CNAME"
},
{
"option": "AAAA"
},
{
"option": "MX"
},
{
"option": "TXT"
},
{
"option": "NS"
}
]
}
}
]
},
"responseMode": "lastNode"
},
"typeVersion": 2.3
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "6e212175-c9e3-40b5-80c7-128e64d07e6b",
"connections": {
"Split Out": {
"main": [
[
{
"node": "For each DNS type",
"type": "main",
"index": 0
}
]
]
},
"DNS Lookup": {
"main": [
[
{
"node": "Set human readable type in output",
"type": "main",
"index": 0
}
]
]
},
"Form input": {
"main": [
[
{
"node": "If no DNS type in input",
"type": "main",
"index": 0
}
]
]
},
"For each DNS type": {
"main": [
[
{
"node": "Aggregate results",
"type": "main",
"index": 0
}
],
[
{
"node": "DNS Lookup",
"type": "main",
"index": 0
}
]
]
},
"Use selected DNS types": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"If no DNS type in input": {
"main": [
[
{
"node": "Default to all DNS types",
"type": "main",
"index": 0
}
],
[
{
"node": "Use selected DNS types",
"type": "main",
"index": 0
}
]
]
},
"Default to all DNS types": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Set human readable type in output": {
"main": [
[
{
"node": "For each DNS type",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 开发运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Typebot 流程与 GitHub 双向同步,使用 Typebot API
Typebot 流程与 GitHub 双向同步,使用 Typebot API
If
Set
Code
+12
31 节点Marcial Ambriz
开发运维
获取所有Scaleway服务器信息副本
通过动态筛选获取Scaleway服务器信息
If
Set
Code
+7
24 节点Pablo
工程
GitHub 同步仪表板 - V2
具有提交历史和回滚功能的 GitHub 工作流版本控制仪表板
If
N8n
Set
+20
94 节点Eduard
开发运维
INST安装程序
打包部署多个n8n工作流 - 含自动凭证映射
If
N8n
Set
+12
31 节点Wyeth
开发运维
潜在客户开发与邮件工作流
使用Google Maps、SendGrid和AI自动化B2B潜在客户开发与邮件营销
If
Set
Code
+21
141 节点Ezema Kingsley Chibuzo
潜在客户开发
使用GPT-4.1、Outlook和Mem.ai自动化Microsoft Teams会议分析
使用GPT-4.1、Outlook和Mem.ai自动化Microsoft Teams会议分析
If
Set
Code
+19
61 节点Wayne Simpson
人力资源
工作流信息
难度等级
中级
节点数量12
分类1
节点类型8
作者
Ossian Madisson
@ossianAI & Automation consultant with many years of experience from both devops and business management. A solid combination to really understand where technology can create real business value. My focus is to help businesses in Sweden work smarter and achieve more by applying technology in a useful and responsible way. Feel free to contact me at ossian@smultronstudio.com or schedule a short call at https://smultronstudio.com
外部链接
在 n8n.io 查看 →
分享此工作流