Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:dpi:dpi_options:dns_substitution [2025/01/17 07:45] – [Configuration] elena.krasnobryzh | en:dpi:dpi_options:dns_substitution [2025/08/13 10:55] (current) – elena.krasnobryzh |
---|
{{tag>Services "Service 19" "DNS Spoofing" "DNS Response Substitution"}} | {{tag>Services "Service 19" "DNS Spoofing"}} |
{{indexmenu_n>16}} | {{indexmenu_n>16}} |
====== DNS Response Substitution ====== | ======DNS Query Processing and DNS Response Spoofing====== |
===== Purpose ===== | =====Purpose===== |
The DNS response substitution service allows changing the IP addresses returned by the DNS server for specific domain names. This allows influencing DNS server responses by overriding IP addresses in server replies for certain types of DNS queries specified in the service settings.\\ | The DNS response spoofing service allows modifying IP addresses returned by the DNS server for specific domain names. This enables influencing DNS server responses by redefining IP addresses in server responses for certain types of DNS queries specified in the service settings.\\ |
This service is effective for controlling client DNS queries and redirecting them to alternative IP addresses. It is particularly useful when you need to direct the user to a different resource than the one requested. | This service is effective for controlling client DNS queries and redirecting them to alternative IP addresses. It is used for load balancing traffic of specific resources between different servers based on IP address. \\ [[en:dpi:dpi_options:opt_li:li_ipfix#configuring_the_export_of_dns_responses_or_dns_queries|Description of DNS query and response export configuration]]. |
| |
==== Service Operation Scheme ==== | ====Service Operation Scheme==== |
- The client makes a specific type of query to the DNS server (e.g., A record type). | - The client makes a specific type of query to the DNS server (e.g., type A). |
- The DNS server returns a response (for A record type, this is an IPv4 address). | - DPI analyzes all DNS queries and checks whether the spoofing service is assigned for this client (source IP) for a specific resource. If blocking is configured for this query, DPI simply drops the DNS query with the specific record type. |
- DPI sees the query and checks if the substitution service is assigned to this client. | - If the service is assigned, DPI drops the client's original DNS query and forms a DNS server response according to the rules specified in the service. |
- If the service is assigned, DPI modifies the original DNS server response according to the specified rules in the service. | - DPI redirects the modified response to the client. The client doesn't notice the modification and considers the response legitimate. |
- DPI forwards the modified response to the client. The client does not notice the modification and considers the response legitimate. | |
| |
===== Configuration ===== | Supported DNS record types: |
- Create a text file and add DNS substitution rules to it by specifying the domain name, DNS record type, and the IP address that will be returned in the response for that domain. Wildcard (*) for domains is supported.\\ Supported DNS record types: | * ''A'' — IPv4 address (32-bit length); |
* A — IPv4 address (length is 32 bits); | * ''AAAA'' — IPv6 address (128-bit length); |
* AAAA — IPv6 address (length is 128 bits).<code bash>vi test.txt | * ''HTTPS'' — this record type is designed to provide information about available services operating over HTTPS. It allows specifying alternative endpoints, HTTP/3 support, ClientHello encryption, and non-standard TCP/UDP ports; |
| * ''MX'' — a TXT record containing information about mail servers handling email. |
| |
| Possible actions with DNS queries: |
| * ''ya.ru HTTPS #drop'' — DPI drops the DNS query with HTTPS record type |
| * ''ya.ru HTTPS #nxdomain'' — DPI responds that the domain doesn't exist for the DNS query with HTTPS record type |
| * ''ya.ru A #nxdomain'' — DPI sends a response about the non-existence of the domain with A record type |
| * ''mail.ru MX smtp.googlemail.com'' — in this case, for a mail.ru query with ''MX'' type, the response should indicate that the mail.ru domain has a mail server at smtp.googlemail.com with a ''preference'' of 10. |
| =====Configuration===== |
| - Create a text file and add DNS query processing rules, specifying: domain name, DNS record type, either an action or IP address, or domain for MX record type that will be included in the response for this domain. Wildcard ''*'' is supported for domains. <code bash>vi test.txt |
google.com A 192.0.2.1 | google.com A 192.0.2.1 |
| test.ru A #nxdomain |
example.com AAAA 2001:db8:85a3::8a2e:370:7334 | example.com AAAA 2001:db8:85a3::8a2e:370:7334 |
*.fb.com A 203.0.113.5</code> | ya.ru HTTPS #drop |
- Use the ''dns2dic'' utility to convert the text file into a binary format understandable by DPI:<code bash>cat test.txt | dns2dic test.bin</code> | *.fb.com A 203.0.113.5 |
- Place the resulting binary file in the directory from which DPI will read it:<code bash>cp test.bin /var/lib/dpi/dns.bin</code> | mail.ru MX smtp.googlemail.com |
| </code> |
| - Convert the text file to a binary format understandable by DPI using the ''dns2dic'' utility:<code bash>cat test.txt|dns2dic test.bin</code> |
| - Place the resulting binary file in the directory where DPI will read it from:<code bash>cp test.bin /var/lib/dpi/dns.bin</code> |
- Create a service profile:<code bash>fdpi_ctrl load profile --service 19 --profile.name test_193 --profile.json '{ "dns_list" : "/var/lib/dpi/dns.bin" }'</code> | - Create a service profile:<code bash>fdpi_ctrl load profile --service 19 --profile.name test_193 --profile.json '{ "dns_list" : "/var/lib/dpi/dns.bin" }'</code> |
| |
===== Management ===== | ''max_profiles_serv19'' — setting for the maximum number of profiles. Default is 32. |
''max_profiles_serv19'' — setting for the maximum number of profiles. The default is 32. | |
| <note tip>By default, the DNS response is sent to the interface from which the query originated (IN interface where the client query was received). Sending to the OUT interface is relevant for asymmetric DPI operation mode (only on outgoing traffic). Configured in ''fastdpi.conf'' with the ''emit_direction=2'' parameter</note> |
| |
| =====Management===== |
Command format: | Command format: |
<code bash>fdpi_ctrl [command] --service 19 [options list] [login or vchannel]</code> | <code bash>fdpi_ctrl [command] --service 19 [options list] [login or vchannel]</code> |
| |
Enabling the service: | Enable service: |
<code bash>fdpi_ctrl load --service 19 --profile.name test_193 --login test | <code bash>fdpi_ctrl load --service 19 --profile.name test_193 --login test |
#or | #or |
fdpi_ctrl load --service 19 --profile.name test_193 --vchannel 1</code> | fdpi_ctrl load --service 19 --profile.name test_193 --vchannel 1</code> |
| |
Disabling the service: | Disable service: |
<code bash>fdpi_ctrl del --service 19 --profile.name test_193 --login test | <code bash>fdpi_ctrl del --service 19 --profile.name test_193 --login test |
#or | #or |
fdpi_ctrl del --service 19 --profile.name test_193 --vchannel 1</code> | fdpi_ctrl del --service 19 --profile.name test_193 --vchannel 1</code> |