Skip to main content
Scientific Reports logoLink to Scientific Reports
. 2026 Feb 4;16:7314. doi: 10.1038/s41598-026-37631-7

DNS fingerprint based on user activity

David Morozovič 1, Michal Konopa 2, Jan Fesl 1,✉
PMCID: PMC12923842  PMID: 41639169

Abstract

The Domain Name System (DNS) plays a critical role in the functioning of the Internet, providing essential resolution services for nearly all user activities. In this work, we examine the hypothesis that individual users exhibit recurrent and distinctive patterns in their DNS query behavior, which can be leveraged to create unique and robust user fingerprints. Building on a publicly available dataset of real DNS traffic collected from a large-scale network, we evaluate the feasibility of user identification solely based on these behavioral DNS traces, independent of IP address stability. We conducted a comparative study of several machine learning models - including Naive Bayes, Random Forests, XGBoost, Multilayer Perceptrons, and Convolutional Neural Networks - on their ability to classify users based on domain category frequencies and derived statistical features. After extensive data preprocessing, dimensionality reduction, and feature selection, our best-performing model (CNN) achieves a classification accuracy of 86.7% across 1727 classes (unique IP addresses). The results confirm the viability of DNS-based user fingerprinting, even in the presence of dynamic IP addresses. Our approach opens new avenues for applications in network forensics and anomaly detection, while also raising important questions about privacy and ethical use of passive traffic analysis.

Keywords: DNS fingerprinting, User, Identification, Behavioral profiling, Internet privacy

Subject terms: Engineering, Mathematics and computing

Introduction

Almost everyone uses the Internet today - whether for education, entertainment or their profession. But do people think about the fact that their online activity can be tracked? That they could be identified purely on the basis of the content they access?

This is the subject of the following article. When a user searches for certain content on the Internet, he or she enters the domain name of the website where the content is located into the browser. This is stored on a specific server. However, computers do not communicate with each other through domains, but through IP addresses. Translating domain names into IP addresses - a task that is handled by the Domain Name System (DNS) - is thus crucial to the very functioning of the Internet.

The motivation for the work on this topic is the impact on the field of cybersecurity. If someone is engaging in illegal activities online, they often try to hide their identity by, for example, frequently changing their public IP address. However, his behaviour may show recurring patterns. It is these patterns that can manifest as a specific and repeatable DNS fingerprint by which he can be identified.

The aim of this paper is therefore to find a way to use machine learning models - including deep learning methods - to identify computers or users based solely on their DNS fingerprint. This includes not only the modelling itself, but also the data analysis and the selection of relevant attributes. Proper selection and data manipulation are key to achieving accurate and reliable results.

It should also be noted that identifying computers and users is not entirely the same task, as multiple users may use the same computer. In practice, users often not only share computers, but also communicate externally via a shared IP address. In this article, and in the created data set, we only had one piece of aggregate data available, namely the IP address. In this case, the IP address can therefore represent both a single user and a group of multiple users.

DNS basics

Even DNS is used by everyone who accesses the Internet today. Ordinary users may not even know that DNS exists. They enter the domain of the website they want to access into their browser, and that’s it. Since IP addresses are hard for people to remember, like telephone numbers, there have been logical efforts to create a more convenient way of interpreting them. For example, the IP address 142.251.37.100 is very well known to everyone, and will probably be even better known by its domain name www.google.com1. DNS is organized in a tree structure. This tree contains a so-called root domain that connects the whole tree. Since there is only one, it is not mentioned in the records (it is an empty string). However, it can be marked with a single dot. The domain is then an arbitrary subtree of the DNS tree. This is followed by the notion of a domain name, which takes the form of simple domains separated by a dot (as an example, www.fit.cvut.cz) and specifies a unique path in the DNS tree, following layers read from right to left1,2.

Nameservers, including root, Top-Level Domain (TLD), and authoritative servers, are responsible for storing DNS records associated with specific domains. When a DNS resolver issues a query, the nameserver either provides a direct answer (if it is authoritative for the domain) or supplies a reference to a nameserver at the next level of the hierarchy (e.g., root or TLD)3.

While the previous list introduced the types of DNS servers involved in the resolution process, it does not explain how the communication between them unfolds. In practice, DNS queries can follow two different resolution strategies: iterative and recursive.

In an iterative resolution the DNS resolver queries each level of the hierarchy sequentially. It begins by asking a root nameserver, which returns a reference to the relevant TLD server based on the domain suffix. The resolver then queries the TLD server, which responds with a reference to the authoritative server. Finally, the resolver contacts the authoritative server to obtain the actual IP address associated with the domain2.

In contrast, a recursive resolution offloads the traversal of the DNS hierarchy onto the nameservers themselves. The resolver submits its query to a root server, which internally forwards the request to the appropriate TLD server. The TLD server then forwards the query to the authoritative nameserver. Once the IP address is resolved, the response is propagated back through the same chain to the resolver2.

User DNS fingerprint

Internet users constantly generate DNS queries as part of routine web activity. Since most domain-to-IP resolutions are carried out via local or public DNS servers (such as 8.8.8.8 or 1.1.1.1), these queries leave behind a persistent behavioral trace-a so-called DNS fingerprint. The queries are typically logged by the respective DNS server and can later be aggregated into structured datasets, as demonstrated in4.

The aforementioned study also discusses the potential applications of DNS fingerprinting and the utility of its associated dataset. A reliable mechanism for user identification can be instrumental in scenarios such as tracing individuals involved in repeated online criminal activity. Notably, a DNS-based identification approach must be resilient to changes in the user’s public IP address, as such changes would render traditional IP-based tracking ineffective.

However, the ability to fingerprint users raises significant privacy concerns. In an era of pervasive data collection, the ethical implications of leveraging DNS fingerprints for behavioral tracking or profiling warrant critical examination.

Paper contribution and organization

This paper presents a structured approach to discovering user-specific DNS fingerprints through the application of machine learning techniques. The core innovation lies in modeling DNS behavior as a function of the user’s repeated access to domain categories over time, thereby uncovering latent behavioral patterns that can serve as identifying signatures. The remainder of the article is organized as follows:

The Introduction outlines the motivation for DNS fingerprinting and highlights potential misuse scenarios. The section Related Work provides a survey of current literature relevant to the problem space, including an overview of mathematical methods and machine learning models applicable to DNS-based user identification. The mathematical methods used in our paper are described in the section Methodology. The description of a previously developed dataset used for training and evaluation it is possible in the section DNS User Fingerprint Dataset. The section Data Preprocessing presents the data preprocessing pipeline, covering steps such as data cleaning and preparation prior to model training. The section Training and Model details the set of machine learning models tested, including their configurations, and presents a comparative performance analysis. The Conclusion offers a summary of the findings and emphasizes the key contributions of the study.

Related work

Several studies have examined DNS traffic and DNS fingerprinting. However, they typically do not focus on identifying individual users via IP addresses, but rather on detecting device types, operating systems, or applications. Often, the datasets used in these studies are not publicly available, which makes it difficult to reproduce the experiments.

A notable exception is the work5 resp.6 of authors, who introduced DNSMiner, a system for constructing behavioral fingerprints based on five dimensions: domain set, domain sequence, time-windowed sequence, periodicity, and hourly activity patterns. Their method operates entirely on passive DNS data and is capable of identifying users even when IP addresses change. Evaluated on 467 million DNS queries from a university network, DNSMiner achieved up to 91% user detection rate with a false positive rate below 1.3%. This work demonstrated the practical feasibility of DNS-based user re-identification at scale and inspired later machine learning–based approaches.

The work7 explores the extent to which users can be assigned a behavioral fingerprint. The data were collected from a DNS server at Bejing University and analyzed using daily and monthly aggregations. The study investigates the consistency of user behavior, such as whether users access websites at the same time on specific days. It also considers application-level activity, as apps leave their own regular fingerprints when, for example, downloading updates. Another motivation is malware detection - infected devices may generate suspicious DNS queries in the background. A general fingerprint helps to identify such abnormal behavior. The study reports an 86% match in monthly behavior and an 80% match for fingerprints based on individual websites. However, users are not directly re-identified, and the dataset is not publicly available.

The study8 uses DNS data from another Peking University. It analyzes logs from three local DNS servers over two days, totaling 349 million DNS queries. The analysis focuses on the 10 most active IP addresses and the 10 most frequently requested domains. To process the large data files, the study uses the DNSReduce method, which splits large files into smaller chunks, processes each individually, and merges the results. The main goal is to visualize user behavior (via charts and tables), not direct prediction. The work also analyzes DNS server loads and anomalies, including behavior of domains with dynamic IPs.

The study9 addresses the identification of IoT devices and highlights their security vulnerabilities due to low-cost manufacturing. It presents the IoTFinder system, which uses machine learning to identify IoT devices within a network. The training data include DNS fingerprints from 53 IoT devices collected over 1.5 months. The classifier uses a binary classification approach, aggregated into a multi-class structure, and is able to identify individual devices behind the same IP, even in NAT environments.

A similar topic is covered in10, which proposes a system to detect IoT botnets using DNS traffic. The study observes periodic device behavior and distinguishes between normal and malware-influenced activity. Infected devices may scan the network and report targets to an attacker, or participate in DDoS attacks. Since domains associated with suspicious websites and compromised devices often change rapidly to evade blocking mechanisms, relying solely on static blacklists proves to be increasingly ineffective. The resulting system detects botnets purely based on DNS data with 90% accuracy.

Botnet detection is also the focus of11, which uses the BotDAD architecture. It comprises two modules: one for processing DNS traffic and generating fingerprints, and another for detecting anomalies using machine learning. DNS fingerprints are formed from hourly aggregates of user activity. The study defines custom features, such as the maximum number of DNS queries per domain or the average number of queries per minute, designed to help detect active malware. From 10 randomly selected days in April and May 2016, a dataset of over 250,000 DNS fingerprints was formed. Unfortunately, only part of the dataset was released publicly. The anomaly detection module employs a Random Forest model, achieving 99% accuracy. BotDAD was also tested on publicly available datasets, where it successfully identified infected devices.

A related approach is presented in12, which also addresses botnet detection through DNS traffic analysis - but instead of machine learning, authors rely on a handcrafted rule-based schema. Their system identifies abnormal query and response patterns using expert-defined rules and achieves 99.35% accuracy with a false positive rate of just 0.25%, demonstrating that lightweight non-learning methods can also be highly effective. Another related solution targeted on the real-time botnet detection can be found in13. In14, the authors used the DNS fingerprinting for the DNS amplification attack detection. The botnet detection seems to be current and future promising direction, which proves the works like15,16 or17.

The study18 proposes a method for detecting operating systems (OS) based on DNS traffic. The key feature used for identification is the set of domain types queried by different OSs. Particularly important are domains that are highly specific to a given OS (e.g., android.clients.google.com). The study also analyzes the temporal patterns of DNS queries and formulates a probabilistic model to estimate the number of operating systems present in a network. Results show that the longer the DNS traffic collection period, the more accurate the prediction. Android OS characteristics are presented as a specific case.

A similar goal is pursued in19, which focuses on identifying mobile applications based on DNS query patterns. Like the previous study, this work emphasizes the domains to which applications send their queries. The reduced dataset used for classification was collected in 2021 and includes 80 mobile applications, each with DNS traffic captured over a 30-hour period. Preprocessing involved simplifying the data, for instance by aggregating domains such as alb.reddit.com, e.reddit.com, preview.redd.it, and v.redd.it into reddit.com, i.e., retaining only the first and second domain levels. The authors point out that domains using content delivery networks (CDNs) often do not follow this naming pattern, and in such cases, it may be necessary to preserve even third-level domains. The same applies to domains with a country-code top-level domain (ccTLD) in the first-level position. Classification in this study is conducted without machine learning, relying instead on a domain matrix that includes the most frequent and unique domains for each app. This lightweight approach achieves over 88% accuracy. A follow-up study by the same authors extended the method by incorporating additional features such as TTL and DNS cache usage, improving classification accuracy to 98%20.

The study21 addresses direct user identification based on DNS traffic. The dataset used originates from a German university in Regensburg and contains DNS queries collected from two local DNS servers between February and June 2010. However, only records from May and June were used for evaluation, as these months exhibited the highest and most diverse online activity among students. During this period, 3,862 unique users were active. DNS logs were aggregated into so-called “epochs”, each representing one day, and transformed into frequency vectors based on accessed domains. Two classifiers were tested: a 1-Nearest Neighbor (1NN) and a Multinomial Naive Bayes (MNB). The best-performing model, based on MNB combined with pattern mining, achieved 85.4% identification accuracy. The study also highlights that users with dynamic IP addresses are more difficult to identify due to fragmented DNS activity across multiple IPs. To disrupt the learned behavioral patterns, users would need to change their IP address frequently-potentially multiple times per day. A conceptually related approach is proposed in22, who also employ a MNB - this time in the context of high - speed network environments. Their method fingerprints devices and users by analyzing DNS query behavior, HTTP User-Agent strings, and web access patterns. Implemented using PFQ and Apache Storm, the system supports real-time traffic processing at multi-gigabit scales. The authors report 77% accuracy in device identification within 60 minutes and 79.5% accuracy in user re-identification within only 5 minutes, underscoring the feasibility of rapid behavioral profiling even without IP-level identifiers.

Building upon the same dataset used in21, the study23 explores user identification through a combination of supervised and unsupervised learning techniques. The DNS data are once again transformed into vector representations, which are then used to construct a matrix where rows correspond to user sessions and columns to domain names. Each matrix entry indicates the frequency with which user A accessed domain j during session i. As a preliminary step before evaluation, the method applies unsupervised learning using a spherical variant of the k-means clustering algorithm. The objective is to generate as many clusters as there are unique users in the dataset. During inference, a new vector is assigned to the cluster whose centroid exhibits the smallest cosine distance from it. Within the selected cluster, user identification is performed based on cosine similarity between the new vector and existing ones; the label of the most similar entry is assigned to the input. The proposed method achieved a test accuracy of 87%. Moreover, the study reports that 55% of users were consistently identified correctly across all test cases. These findings once again raise concerns about privacy, as user profiling via behavioral DNS analysis is virtually undetectable from the user’s perspective.

A noteworthy unsupervised approach was proposed in24, which demonstrates that behavioral patterns in DNS sessions can be effectively clustered to reveal recurring user identities. Their method, based on Dirichlet mixture modeling and modified k-means clustering, does not require any labeled data and links user sessions even when IP addresses change. This contribution highlights the potential of behavior-based user tracking in large-scale environments where traditional identifiers are unavailable.

Study25 introduces an open-world DNS fingerprinting approach capable of re-identifying users whose identities were not seen during training. Their method, called DSCORR, leverages word2vec-style domain embeddings and user-specific similarity thresholds to link DNS sessions across time. The model achieves an AUROC of 0.87, significantly outperforming earlier techniques. In addition to this attack method, the authors propose a privacy defense mechanism LDPRESOLVE based on local differential privacy. This mechanism significantly reduces identification accuracy from 93% to 10%. The problem with such a study lies in the data set used, which is not well-documented and accessible. Due to this fact, the achieved results cannot be verified and reproduced. The accuracy was achieved for a specific, limited case and can’t be considered as a generic fact.

Another recent work that implicitly operates in an open-world setting is presented in26, which proposes a deep-learning approach for detecting malicious DNS behavior using a hybrid Transformer-CNN architecture. Their model captures both long-range dependencies and local structural features in DNS sequences, enabling the detection of previously unseen threat patterns. Evaluated on a combination of real-world and DGA datasets, the system achieves 95.8% accuracy, 96.8% detection speed, and 97.6% overall performance, surpassing earlier baselines. This study underscores the potential of neural architectures not only for user tracking but also for adaptive anomaly detection in dynamic DNS environments.

Methodology

This section provides a theoretical background for the methodologies applied in identifying users within this study. Specifically, user identification refers to the task of distinguishing between individual IP addresses. The analysis is conducted using the publicly available dataset introduced in4, framing the task as an experimental classification problem whose outcomes may inform public discourse and advanced investigations into DNS fingerprinting.

The following sections outline the practical methodology adopted in this work, followed by a review of advanced preprocessing techniques and predictive modeling approaches.

Dimensionality reduction

High-dimensional datasets frequently pose challenges in optimization and classification tasks. Excessive dimensionality not only increases computational costs but can also degrade model performance. This issue is commonly referred to as the curse of dimensionality.

One straightforward approach to mitigating high dimensionality is manual feature selection. Features with low variance or high redundancy can often be identified through initial data exploration and removed. However, manual approaches may be infeasible or insufficient for very high-dimensional data. In such cases, feature transformation methods can provide substantial benefits by projecting the data into a lower-dimensional space while preserving essential information.

Among the most widely used techniques are Principal Component Analysis (PCA) and t-distributed Stochastic Neighbor Embedding (t-SNE). The latter aims to preserve local similarity structures using the Kullback-Leibler divergence to measure the difference between probability distributions27–29.

Normalization

Normalization is a standard preprocessing technique, particularly important for models that rely on distance measures such as neural networks, SVMs, or k-nearest neighbors (kNN). When features have different scales, those with larger magnitudes may dominate and mislead the model. Normalization rescales features to a common range or distribution, allowing all inputs to contribute fairly. Common approaches include min-max normalization and z-score standardization.

Machine-learning models

Besides preprocessing, the selection of predictive models is crucial to the success of classification tasks. This work investigates both traditional machine learning algorithms and modern deep learning architectures. This work does not provide an in-depth explanation of the internal workings of these models, as such detail lies outside the intended scope of the study.

Various models can be employed to classify DNS traffic, including decision trees, kNN, and logistic regression. Nonetheless, effective prediction across dozens to thousands of classes necessitates the use of more robust and stable modeling approaches.

Random forests, as used in11, have demonstrated excellent accuracy in botnet detection. Work30 compares multiple models in a multiclass setting and confirms the strength of random forests and their enhanced variants.

Alternatives to random forests include ensemble-based methods such as AdaBoost and the increasingly popular XGBoost. While both approaches leverage decision trees, they differ in their training dynamics. Studies31 and32 highlight their stability and effectiveness, including on imbalanced data.

The study31 also evaluates the performance of Naive Bayes and multilayer perceptrons, with Naive Bayes proving effective for user identification in21.

Within the family of neural networks, both the standard multilayer perceptron (MLP) and the convolutional neural network (CNN) are worth exploring. CNNs are well-known for their performance on image data. Given the nature of the features in this task-specifically the domain category attributes (see “Feature types” and “Domain categories”) - it is conceptually intriguing to interpret the DNS fingerprint as a structured ’image’ composed of these features.

Evaluation metrics

Evaluating predictive models requires suitable performance metrics. The most commonly used include accuracy, precision, recall (sensitivity), and the F1-score. These metrics are derived from the confusion matrix as shown in Table 1.

Table 1.

Confusion matrix for binary classification.

Reality
Inline graphic Inline graphic
Prediction   Inline graphic True positive (TP) False positive (FP)
Inline graphic False negative (FN) True negative (TN)

The recall, or true positive rate (TPR), estimates Inline graphic:

graphic file with name d33e609.gif

Precision, or positive predictive value (PPV), is Inline graphic

graphic file with name d33e619.gif

The F1-score is the harmonic mean of precision and recall:

graphic file with name d33e624.gif

The accuracy metric measures overall correctness, Inline graphic:

graphic file with name d33e632.gif

For multiclass problems, averaging methods are applied. Micro-averaging aggregates all class counts into a single ratio, which can mask class imbalance. Macro-averaging, used in this study33, computes each metric per class and averages the results, treating all classes equally. For a classification problem with k classes, the metrics are defined as follows.

graphic file with name d33e650.gif

DNS user fingerprint dataset

The dataset employed in this study, was created by our team, is publicly available and thoroughly described in the article A user DNS fingerprint dataset4. This open access allows researchers to independently analyze the data, verify results, and contribute further insights. Its availability promotes transparency and encourages broader adoption of DNS fingerprinting techniques within the academic community.

The dataset is derived from real-world DNS traffic, which presents both opportunities and challenges. If a substantial portion of users exhibit similar behavioral patterns, distinguishing individuals could become highly complex. Moreover, the size of the monitored network and the duration of the data collection period significantly impact the granularity and variability of the data. A larger-scale dataset-e.g., from a global provider like Cloudflare would likely increase complexity and pose additional analytical challenges.

The data was collected within a local ISP network by converting DNS logs into CSV format. Each CSV file contains daily aggregated statistics for every active IP address within the network. The data collection spanned three months, from December 2023 to February 2024.

Our dataset contains all records originating from IPv4 traffic. DNS domain records contain one specific record type called AAAA for IPv6 addresses (the A record type is the IPv4 equivalent). The DNS user fingerprinting proposed in the following sections can be easily adapted to IPv6 traffic by treating A and AAAA records as the same.

Two main variants of the DNS fingerprint files are provided, each organized into separate directories. One variant lists domain names in plain text, while the other encodes these domains as numeric hashes. A mapping file is included, linking each domain string to its unique hash. These hashes are optimized for computational processing and are the primary format used in this study.

In total, there are 90 CSV files of each type, organized by month. Each daily file contains statistics for approximately 1,800 to 2,000 unique IP addresses. The target variable in this study is the feature IP ID, which uniquely identifies each address. The dataset includes a total of 1,137 features (see “Feature types”).

Feature types

The dataset distinguishes between two main types of features: 105 daily summary features (including IP ID) and 1,032 hourly features. The overall structure is depicted in Fig. 1, with a more detailed breakdown provided in Fig. 2. This work focuses solely on daily summary statistics, as shown under the Daily records section of Fig. 1. The goal is to determine whether these aggregated statistics are sufficient to accurately identify users or applications.

Figure 1.

Figure 1

Basic categorization of features present in the dataset.4.

Figure 2.

Figure 2

Detailed categorization of dataset features.4.

An advantage of DNS-level data collection is the uniformity of logged values. No column contains conflicting data types, ensuring clean preprocessing. Feature data types are as follows:

  • int64 103 features,

  • float64 2 features.

While most features are encoded as integers, some represent hashed domain identifiers. Although numerical, these are categorical variables and require special handling (see “Feature selection”).

The two float64 features - Average daily user activity and Average hourly query count - are derived from other attributes. The latter is computed as the mean of Max hourly query count and Min hourly query count, while the former represents Daily query count divided by 24. In both cases, the result is rounded down to the nearest integer.

Domain categories

The dataset contains 386,218 unique domains queried via DNS. To facilitate analysis, these domains are grouped into 75 predefined content categories, as defined by IBM X-Force Exchange. These categories reflect the type of content users regularly access and are a central component of the aggregated classification features. Each category stores the number of DNS queries made to domains of that content type per day.

As shown in Fig. 3, the General Business category accounts for over one-third of all DNS queries. This category includes 135,019 unique domains. One might infer a positive correlation between the number of queries and the number of distinct domains per category. However, the Unknown category-although containing the second-highest number of unique domains (118,134)-represents less than 5% of all queries, indicating that domains in this category are queried far less frequently.

Figure 3.

Figure 3

Distribution of domain categories across all DNS queries.

Data preprocessing

Data preprocessing is the first step in machine learning, during which data are transformed or encoded into a format that allows machines to efficiently process or analyze them... It is considered the most crucial stage, with the greatest impact on the generalization performance of supervised learning algorithms34.

Record filtration

The dataset contains 171,623 records distributed across 4,053 IP addresses. On average, each IP address was active for 42 days over a three-month period. For machine learning models to effectively learn to predict the present classes, each class must be sufficiently represented. Ideally, the number of records per class should be balanced. If not, a class imbalance problem arises, leading to bias in favor of more frequent classes. This may result in seemingly higher accuracy but typically degrades the F1 score. Such a model cannot be considered robust, as its predictions lack sufficient generalization.

To mitigate this, we retain only those IP addresses that appear in at least 80% of all possible days (i.e., at least 72 days). A total of 1,727 (42.6%) IP addresses meet this criterion, accounting for 153,462 (89.4%) DNS queries.

An 80% presence threshold offers a balanced approach to filtering: it preserves a substantial number of IP addresses and maintains the task’s complexity. While removing 57% of IP addresses might seem overly strict, nearly 90% of DNS queries remain, emphasizing classes that reflect meaningful behavior rather than noise. Moreover, this threshold removes the need for artificial class balancing.

Feature selection

Given the nature of the task, certain attributes merit closer scrutiny. Some may be too complex for machine learning models to interpret, while others offer negligible information and unnecessarily increase dimensionality.

The features labeled X most regularly visited domain, where X ranges from 0 to 9, are categorical. To retain these features, one-hot encoding would be required. However, this transformation significantly increases dimensionality, as each unique value generates a new binary feature. Based on the data summarized in Table 2, this would result in over 20,000 new binary features. While each IP typically has 5-23 unique domains in these fields, which could aid identification, the dimensional growth is excessive. Even encoding domains as ordinal categories would still add hundreds of dimensions. Hence, these categorical features are excluded.

Table 2.

Unique domain counts in categorical features and average number of domains per IP (training data).

Feature Domain count Average domains per IP
0 most regularly visited domain 1210 5.51
1 most regularly visited domain 1817 10.58
2 most regularly visited domain 2094 13.15
3 most regularly visited domain 2375 14.98
4 most regularly visited domain 2551 16.42
5 most regularly visited domain 2693 17.51
6 most regularly visited domain 2885 19.39
7 most regularly visited domain 3010 20.71
8 most regularly visited domain 3148 22.17
9 most regularly visited domain 3261 23.25

Next, we remove features that carry no informational value. For example, Botnet Command and Control Server contains only zero values in the training set. Similarly, the feature Sects has only a single non-zero entry. Both are thus constant or nearly constant and removed.

The features Daily query count, Average daily user activity, and Average hourly query count are also removed. These are derived via linear combinations or transformations of other features, making them redundant. Specifically, Daily query count is the sum of all category-specific DNS query counts (Abortion,...,Web Storage). Redundant features not only increase computational cost but may also lead to numerical instability in models.

Normality testing

Many statistical methods assume normally distributed data. Normality is typically assessed using the Shapiro-Wilk test, the Kolmogorov-Smirnov test, or the Anderson-Darling test35.

Figure 4 presents Q–Q plots of selected features. Similar patterns are observed across all features. For normality to be assumed, points should align along the line defined by the first and third quartiles (Inline graphic and Inline graphic) of the theoretical and empirical distributions. This condition is clearly violated, suggesting the data are not normally distributed.

Figure 4.

Figure 4

Q–Q plots of selected features (training data).

Feature correlation

Analyzing linear dependencies among features is a key part of preprocessing. Preliminary assessments were made in “Feature selection”, focusing on visually obvious dependencies. Here, we extend the analysis using a correlation matrix, which displays pairwise correlation coefficients to reveal interdependencies. The two most common metrics are Pearson’s and Spearman’s correlation coefficients.

Pearson’s coefficient is parametric, relying on sample means and assuming continuous, normally distributed, and independent observations. It only detects linear relationships. When normality is violated, Spearman’s non-parametric alternative is preferred36.

In literature, an absolute correlation above 0.7 is considered strong. Figure 5 displays features with absolute correlations above 0.75, for clarity. Strong correlations are especially evident among Occurrence of X most regularly visited domain features, with coefficients exceeding 0.9. These are prime candidates for removal. High correlation is also observed between Daily unique domain count and some domain category features. Despite this, Daily unique domain count is retained as it provides unique insight - the total number of visited domains is a fundamental metric, even if it correlates with specific category counts.

Figure 5.

Figure 5

Correlation matrix of selected features, Spearman coefficient > 0.75, training data.

Feature correlation

The Variance Inflation Factor (VIF) is a standard method for detecting multicollinearity. It is based on the coefficient of determination. A VIF value above 10 is generally problematic37, though some sources flag values above 5. The 5-10 range is often considered a grey area, where decisions rely on domain expertise.

VIF measures how well a feature Inline graphic can be explained by a linear combination of the other features. It is calculated using the least squares method to estimate the proportion of variance in Inline graphic accounted for by the others.

Table 3 lists features with VIF > 5. Almost all Occurrence of X most regularly visited domain features are included, with VIFs sometimes exceeding 100. VIF tends to increase with X, except for hours 5-6 and 8-9, where it decreases. Therefore, we remove hours 1-4 and 6-8, preserving hours 5 and 9 due to their reduced VIFs. Other features like Anonymisation Services and Daily unique domain count also show multicollinearity and are addressed accordingly. We remove Max hourly query count, Computer Games, and Pornography.

Table 3.

Features with VIF > 5 (training data).

Feature VIF
Daily unique domain count 5.86
Max hourly query count 17.81
Anonymisation Services 6.51
Computer Games 19.60
Pornography 19.32
Software/hardware 15.38
Occurrence of 1 most regularly visited domain 12.06
Occurrence of 2 most regularly visited domain 45.98
Occurrence of 3 most regularly visited domain 58.67
Occurrence of 4 most regularly visited domain 62.66
Occurrence of 5 most regularly visited domain 42.84
Occurrence of 6 most regularly visited domain 49.13
Occurrence of 7 most regularly visited domain 99.18
Occurrence of 8 most regularly visited domain 147.45
Occurrence of 9 most regularly visited domain 84.41

The results after removing the aforementioned features are shown in Table 4. VIF values for hours 5 and 9 decrease significantly, and these features are retained. Software / Hardware and Anonymisation Services now also have acceptable VIFs. A few features still slightly exceed the VIF threshold of 5, but these are deemed acceptable. The rationale for retaining Daily unique domain count was discussed in Sect. 5.2.

Table 4.

Features with VIF greater than 5 after selected removals (training data).

Feature VIF
Daily unique domain count 5.83
Occurrence of 5 most regularly visited domain 5.68
Occurrence of 9 most regularly visited domain 5.51

Outlayer filtering

Earlier normality tests suggested the presence of outliers. DNS query count is a logical metric for identifying them, as it underpins most features and best reflects user activity. Checking each domain category individually would highlight any user with moderate activity, which is unhelpful.

We therefore reconsider the Daily query count feature, previously removed for redundancy. As it aggregates all category-specific DNS queries, it offers a balanced summary. Outliers are identified based on this feature.

The method used is a modified version of the interquartile range (IQR) rule. It marks values as outliers if they lie outside:

graphic file with name d33e1180.gif

The constant 1.5 typically identifies about 1% of values as outliers under normal distribution assumptions. However, in multi-class classification with limited samples per class, this threshold may be too aggressive. Excessive filtering could distort the dataset.

Thus, we adopt a more lenient threshold of 3. This results in 1,646 outliers being removed from the 107,423 training records.

Figure 6 shows how outlier removal affects distances between records using hierarchical clustering. The distance metric used is Euclidean, and average linkage is applied.

Figure 6.

Figure 6

Dendrograms of hierarchical clustering for selected IPs, before and after outlier removal (average linkage, Euclidean distance).

The complete list of features available after applying of all filtration methods has been provided in Appendix ??.

Data visualization

Following the preprocessing of the (training) dataset, it was possible to visualize the records. As the data are high-dimensional, a dimensionality reduction method is needed to project them into 2D or 3D space. A suitable method is t-SNE, which allows for meaningful projections that preserve local structure. Visualization serves as an intuitive tool to estimate the effectiveness of preprocessing and to assess whether individual IP addresses (i.e., classes) are separable.

To maintain clarity, the visualization was performed on a random subset of 30 IP addresses rather than the entire training set.

In Fig. 7, we observe that most IP addresses form compact, well-separated clusters in the 2D space. This suggests that, with appropriate hyperparameter tuning, the models should achieve high predictive performance. Additionally, Fig. 8 presents a 3D projection of the same data, which reveals further structure and orientation differences among clusters.

Figure 7.

Figure 7

2D t-SNE projection of a random sample of 30 IP addresses.

Figure 8.

Figure 8

3D t-SNE projection of a random sample of 30 IP addresses.

Dimensionality reduction

The final section of the data preprocessing chapter focuses on linear transformation using Principal Component Analysis (PCA). The goal is to reduce the dimensionality of the dataset (from p to q features) while preserving as much information as possible. Specifically, PCA seeks directions in the feature space that maximize the variance of the original data.

Given the complexity of classifying 1,727 unique IP addresses, overly aggressive dimensionality reduction could render some classes indistinguishable. Projecting multiple classes onto similar locations in the q-dimensional subspace Inline graphic would impair prediction. Therefore, the chosen dimensionality must balance simplification and information preservation. The motivation for dimensionality reduction includes removal of residual redundancy and the desirable properties of principal components, such as mutual uncorrelatedness.

This is where the scree plot proves useful. It visually summarizes how much of the total variance is captured by each principal component. The components are ordered by explained variance. The optimal number of components can often be selected by identifying the “elbow point” - the location in the plot where the steep descent transitions to a more gradual slope.

Crucially, PCA is applied to standardized data in this study. Since PCA maximizes variance, features with larger scales would dominate the resulting components unless standardized. Standardization ensures a fair representation of all features.

As shown in Fig. 9, the elbow appears quite early, around the second component. The first principal component explains just over 10% of the total variance, while no subsequent component explains more than 3% individually.

Figure 9.

Figure 9

Scree plot of the proportion of variance explained by principal components.

Therefore, we adopt a strategy of retaining the top 50 principal components during model training. This threshold is justified by the observation that after the 50th component, the variance explained per component drops below 1%. Collectively, the first 50 components account for approximately 81.5% of the total variance - an acceptable trade-off between dimensionality reduction and information retention.

Model training and evaluation

This section focuses on training the models introduced earlier. The evaluation uses the metrics described in previous section, with accuracy serving as the primary metric. We also used the metrics Predictable classes able to quantify how many classes (users identified by their IP addresses) can be distinguished by the used model resp. by the used input data type.

Supporting metrics include recall, precision, and F1 score. These values help verify model performance; significant deviation among them would indicate class imbalance in the predictions.

The dataset split was chosen in the ratio of 70/15/15 (training/validation/test) considering the content and size of the dataset.

The models were implemented in Python using the scikit-learn and PyTorch libraries. Training was performed on a machine equipped with an NVIDIA GeForce RTX 2070 GPU, an Intel Core i5-10400F processor, and 16 GB of RAM.

Each model was trained on four variants of the dataset: the raw data, data normalized using min-max scaling, standardized data, and PCA-transformed data.

Feature importance interpretation methods

One of the objectives of this paper is to interpret the importance of features used in predictive models. This helps reveal whether some features are consistently emphasized across models and are therefore generally valuable for prediction. It is particularly informative to observe how different models respond to specific features.

A popular method for evaluating feature importance is SHAP (SHapley Additive exPlanations)38. Rooted in game theory, SHAP can be applied to any model type and provides a unified framework for interpreting feature relevance. However, its computational demands are substantial, especially when working with large datasets and many output classes.

Some models offer built-in mechanisms for interpreting feature importance. For instance, Random Forest uses the Mean Decrease in Impurity (MDI), which reflects how much a given feature contributes to reducing impurity (measured by entropy or the Gini index) during splits in the decision trees. The importance vale can be obtained by calling the function feature_importances_.

XGBoost also includes a native feature importance method through the get_score function. When used with the gain parameter, it evaluates the average improvement in the loss function resulting from splits on a given feature.

Other models used in this study - Naive Bayes, MLP, and CNN - do not provide built-in importance scores. For these, the Permutation Feature Importance method is employed. It operates on a simple principle: the values of each feature are randomly shuffled (independently), and the resulting drop in model performance indicates the feature’s relevance.

While Permutation Feature Importance can be applied to any model, it is not used for tree-based methods here due to the computational burden of evaluating their predictions.

Naive Bayes classifier

The scikit-learn library offers several variants of the Naive Bayes classifier. For the structure of this dataset, MultinomialNB proved most appropriate, as it assumes that the data follow a multinomial distribution - i.e., features take non-negative integer values and are conditionally independent. Because of this, applying min-max, standardization, or PCA is not suitable for this model.

An alternative is BernoulliNB, which converts feature values to binary (0 or 1) using the binarize hyperparameter. This allows its application across all dataset variants, including min-max, standardized or PCA-transformed data.

A third theoretical option is GaussianNB, which assumes features are continuous and normally distributed. While predictions can still be produced, this assumption does not hold for the given dataset, and the model’s stability is questionable. Therefore, it was not included in this study.

Aside from binarize, the only hyperparameter to tune is alpha, which controls Laplace smoothing. The best result was obtained with MultinomialNB using alpha = 1e-12, as shown in Listing 1.

graphic file with name 41598_2026_37631_Figa_HTML.jpg

Listing 1 Naive Bayes Classifier: Hyperparameter configuration used for final training.

Based on the results in Table 5, it can be concluded that the Naive Bayes classifier did not perform well. The training process of this model, together with the intermediate results, is illustrated in Fig. 10. The BernoulliNB model failed to adapt to the data. Although the best configuration - with alpha set to 1e-12 - achieved a validation accuracy of 66%, this falls short of the performance level established by the XGBoost model. The only notable positive is that the model was able to predict over 96% of the classes, which is respectable considering that it relies solely on conditional probabilities. The values of recall, precision, and F1-score, as shown in Table 6, were very close to the accuracy.

Table 5.

Naive Bayes classifier: final metric values after training.

Model Data type Training accuracy Validation accuracy Predictable classes (%)
MultinomialNB Raw 0.686 0.661 1665 (96.4%)
BernoulliNB Min-max 0.399 0.347 1571 (91.0%)
BernoulliNB Standard. 0.561 0.514 1559 (90.3%)
BernoulliNB PCA 0.306 0.271 1601 (92.7%)

Figure 10.

Figure 10

Naive Bayes classifier: training progress - model trained on raw data.

Table 6.

Naive Bayes classifier: additional validation metric values.

Model Data type Validation precision Validation recall Validation F1 score
MultinomialNB Raw 0.690 0.660 0.655
BernoulliNB Min–max 0.343 0.344 0.319
BernoulliNB Standard. 0.567 0.513 0.521
BernoulliNB PCA 0.299 0.270 0.257

In terms of feature importance (Fig. 11), the model heavily relied on the most frequent features and was unable to leverage rare ones - a reflection of its underlying assumptions.

Figure 11.

Figure 11

Naive Bayes classifier: top 20 most important features.

Random forest

Two hyper-parameters play a particularly important role in Random Forests: the number of decision trees and the maximum depth of each tree. Depth must be chosen carefully; too shallow leads to underfitting, while too deep increases the risk of overfitting and excessive memory usage. In fact, when the depth exceeded 10, RAM capacity became a limiting factor. On the other hand, a larger number of trees generally helps the model capture more data structure.

Hyperparameter tuning was done iteratively, starting from a randomly selected configuration. Based on intermediate results, some options were retained and others discarded. For example, the Gini index as a decision criterion yielded results up to one third worse compared to using entropy.

Using this method, a refined subset of tuned hyper-parameters was obtained, as shown in Listing 2. The n_jobs parameter determines how many CPU cores are allocated for training, while class_weight ensures that all classes are treated equally, regardless of frequency in the training set.

Table 7 shows the training and validation accuracies achieved across all data variants. Listing 2 presents the best-performing hyperparameter combination.

graphic file with name 41598_2026_37631_Figb_HTML.jpg

Listing 2 Hyperparameter configuration of the Random Forest model for final training.

Table 7.

Random Forest: final model metric values after training.

Data type Training accuracy Validation accuracy Predictable classes (%)
raw 0.819 0.727 1676 (97.0%)
min-max 0.820 0.728 1673 (96.9%)
standard. 0.822 0.729 1686 (97.6%)
PCA 0.623 0.432 1702 (98.6%)

The results indicate that training on raw, min-max, and standardized data yields nearly identical performance, as reported in Tables 7 and 8. This is expected because decision trees split data based on thresholding a specific feature, and scaling only shifts the threshold values. However, standardized data slightly outperformed the others. In contrast, PCA performed poorly. Random Forest struggled to work effectively with data in the transformed space. All models were able to predict the vast majority of classes.

Table 8.

Random Forest: additional validation metric values.

Data type Validation precision Validation recall Validation F1 score
raw 0.768 0.726 0.718
min-max 0.769 0.727 0.719
standard. 0.768 0.727 0.720
PCA 0.487 0.431 0.399

Training progress for the standardized data variant is shown in Fig. 12. Training accuracy stabilized around 80%, while validation accuracy hovered near 70%. The validation precision reached 0.768, but recall and F1 score were 0.727 and 0.720, respectively - consistent with overall accuracy and indicating balanced performance.

Figure 12.

Figure 12

Random Forest: training progress - model trained on standardized data.

Feature importance derived from the MDI method is illustrated in Fig. 13. The most influential features were General Business and Software / Hardware, which together represented 47.4% of all DNS queries. Notably, Occurrence of 5 most regularly visited domain and Occurrence of 9 most regularly visited domain features that were nearly excluded due to high VIF were among the top 20, validating their inclusion.

Figure 13.

Figure 13

Random Forest: top 20 most important features.

XGBoost

Among all models evaluated, XGBoost was the most computationally demanding to train, which limited the extent of hyperparameter exploration. However, intermediate results showed that the model’s performance remained unchanged when the maximum allowed tree depth was set to 4 or 5.

As with the Random Forest, training started with a randomly selected configuration. This configuration was gradually refined based on model performance. Although the xgboost library supports GPU acceleration via the device parameter, the large number of unique classes in the dataset reduced its computational efficiency.

The final set of hyperparameters used for training is shown in Listing 3.

graphic file with name 41598_2026_37631_Figc_HTML.jpg

Listing 3 XGBoost: Hyperparameter configuration used for final training.

Tables 9 and 10 summarize the achieved training and validation results. As expected with tree-based models, performance across raw, min-max, and standardized data was nearly identical.

Table 9.

XGBoost: final metric values after training.

Typ dat Training accuracy Validation accuracy Predictable classes (%)
Raw 0.945 0.814 1712 (99.1 %)
Min–max 0.945 0.815 1715 (99.3 %)
Standardized 0.945 0.815 1710 (99.0 %)
PCA 0.950 0.581 1725 (99.9 %)

Table 10.

XGBoost: additional validation metric values.

Data type Validation precision Validation recall Validation F1 score
raw 0.821 0.812 0.813
min-max 0.821 0.813 0.813
standard. 0.822 0.813 0.813
PCA 0.596 0.580 0.579

Where XGBoost stood out was its ability to surpass 80% validation accuracy and distinguish more than 99% of the IP addresses. These results demonstrate that the boosting approach is highly effective for multi-class classification tasks. Although min-max and standardized data achieved the same rounded validation accuracy, there were minor differences beyond the first decimal place.

Interestingly, the PCA-transformed model achieved the highest training accuracy and could identify 1,725 of the 1,727 classes. However, its validation accuracy dropped sharply, indicating overfitting.

graphic file with name 41598_2026_37631_Figd_HTML.jpg

Listing 4 XGBoost: best combination of hyperparameter values.

The best results were obtained using L2 regularization (lambda = 2), as shown in Listing 4. XGBoost was the only model to benefit significantly from this form of regularization.

Intermediate results during training remained highly similar, consistently producing training accuracy above 94%. For the top-performing model, validation recall, precision, and F1 score reached 0.813, 0.822, and 0.813, respectively - indicating a well-balanced model. Figure 14 illustrates the training process of this model.

Figure 14.

Figure 14

XGBoost: training progress - model trained on standardized data.

Figure 15 shows that the most informative features for the model were those that occur relatively infrequently in the dataset. Another noteworthy observation is that the best-performing model based its predictions independently on three specific features: the domain categories Early Warning, Malware, and Political Extreme / Hate / Discrimination.

Figure 15.

Figure 15

XGBoost: top 20 most important features.

Multilayer perceptron

Neural networks are currently regarded as the most promising models for achieving strong performance. Owing to their architecture, they are well suited to capturing nonlinear structures in data - an ability that is often essential.

Hyperparameter tuning for neural networks can be challenging due to the many configuration options and lack of fixed architectural rules. In this study, tuning followed a methodology similar to that used for Random Forest and XGBoost: starting from a basic architecture and iteratively increasing its complexity.

The loss function used was cross-entropy loss, and the optimizer was Adam. Simpler methods like stochastic gradient descent (SGD) failed to train the model effectively. These same settings were also used for CNNs.

While the optimizer and loss function were fixed, their parameters were optimized. For cross entropy loss, label_smoothing was tuned to help regularize the model by preventing overconfidence in predictions - a useful technique when working with many classes. For the Adam optimizer, the learning rate was tuned, as values that are too small slow convergence, while overly large values may cause the optimizer to overshoot the minimum.

The tuning began with a shallow network and few neurons, followed by adjustments to the number of neurons and addition of hidden layers. Once a promising structure was found, various activation functions were tested. Although ReLU was used as the default, SELU yielded the best results. The learning rate, label smoothing, and use of dropout were then optimized to improve generalization.

Training was set to a maximum of 400 epochs with early stopping after 100 epochs of no improvement. This gave the model sufficient time to converge while guarding against overfitting.

The results in Tables 11 and 12 show that all MLP variants achieved validation accuracies above 80%, including the model trained on PCA-transformed data. The best-performing model used standardized input data and reached 83.2% validation accuracy, successfully classifying over 96% of the IP addresses.

Table 11.

Multilayer perceptron: final metric values after training.

Data type Training accuracy Validation accuracy Predictable classes (%)
Raw 0.925 0.824 1710 (99.0%)
Min-max 0.892 0.826 1636 (94.7%)
Standard. 0.917 0.832 1661 (96.2%)
PCA 0.905 0.809 1661 (96.2%)

Table 12.

Multilayer perceptron: additional validation metric values.

Data type Validation precision Validation recall Validation F1 score
Raw 0.830 0.822 0.820
Min-max 0.839 0.824 0.823
Standard. 0.836 0.830 0.828
PCA 0.822 0.808 0.807

The architecture of this final model included 7 hidden layers, dropout at two levels, label_smoothing = 0.3, and learning rate = 0.0005. L1 regularization did not improve performance. The model’s validation recall, precision, and F1 score were 0.830, 0.836, and 0.829, respectively, indicating good balance. The training progression over epochs is illustrated in Fig. 16.

Figure 16.

Figure 16

Multilayer perceptron: training progress - model trained on standardized data.

Figure 17 shows that the most influential features included common domain categories, as well as Occurrence of 5 and 9 most regularly visited domains. Similar to the Random Forest model, retaining these features proved to be a beneficial decision.

Figure 17.

Figure 17

Multilayer perceptron: top 20 most important features.

Convolutional neural network

The final model evaluated was the Convolutional Neural Network (CNN), which extends the MLP architecture with convolutional and pooling layers. CNNs are commonly used for image, text, sequence and time series data. In this context, domain categories can be thought of as forming a structured representation.

As with the MLP, the CNN was trained using the cross entropy loss function and the Adam optimizer, with a maximum of 400 epochs and early stopping set to 100. The training procedure also included tuning of convolutional and pooling layers. Key parameters included kernel size, number of input/output channels, stride, and padding. Pooling layer configuration involved kernel size and stride. The final architecture is illustrated in Fig. 18.

Figure 18.

Figure 18

CNN: detailed layer-by-layer architecture of the network.

Tables 13 and 14 show that the CNN outperformed all previous models. With min-max normalized data, it achieved a validation accuracy of 86.7% and successfully predicted 1694 of 1727 classes. Control metrics further confirmed its robustness: recall = 0.866, precision = 0.871, and F1 score = 0.864. These indicate that the model made accurate and balanced predictions. The training progress of the best model is illustrated in Fig. 19.

Table 13.

Convolutional neural network: final metric values after training.

Data type Training accuracy Validation accuracy Predictable classes (%)
Raw 0.923 0.861 1689 (97.8%)
Min-max 0.931 0.867 1694 (98.1%)
Standard. 0.915 0.849 1657 (95.9%)
PCA 0.899 0.791 1638 (94.8%)

Table 14.

Convolutional neural network: additional validation metric values.

Data type Validation precision Validation recall Validation F1 score
Raw 0.867 0.859 0.858
Min-max 0.871 0.866 0.864
Standard. 0.856 0.847 0.846
PCA 0.802 0.789 0.787

Figure 19.

Figure 19

Convolutional neural network: training progress - model trained on min-max.

Further observations during training include the following: kernel sizes of 2 and 3 worked best; L1 regularization and large strides had a negative impact; basic padding proved helpful; dropout layers contributed positively; and pooling layers consistently reduced performance. Therefore, no pooling was used in the final CNN models.

As shown in Fig. 20, the CNN prioritized many of the same domain categories as the MLP. However, the top three features had a stronger influence, suggesting slightly greater reliance on the most dominant signals.

Figure 20.

Figure 20

Convolutional neural network: top 20 most important features.

Model comparison and user DNS fingerprint

This subsection summarizes the results of all evaluated models. Table 15 compares the best-performing configuration of each model. Based on the primary metric -validation accuracy - the convolutional neural network trained on min-max normalized data achieved the best performance overall.

Table 15.

Summary table of the best results achieved by all models.

Model Data type Training accuracy Validation accuracy Predictable classes (%)
Random Forest Standard. 0.822 0.729 1686 (97.6%)
XGBoost Standard. 0.945 0.815 1710 (99.0%)
Naive Bayes Raw 0.686 0.661 1665 (96.4%)
MLP Standard. 0.917 0.832 1661 (96.2%)
CNN Min-max 0.931 0.867 1694 (98.1%)

The MLP and XGBoost also performed strongly. In particular, XGBoost appears promising for future applications due to its robustness and ability to distinguish nearly all IP addresses. While Random Forest and Naive Bayes performed worse in comparison, their results - 72.9% and 66.1% accuracy across 1,727 classes - are still respectable.

All models presented in Table 15 rely heavily on features that reflect user-specific activity patterns. Selecting the most informative subset of features is a highly complex task - particularly given the large number of available features - and becomes practically intractable through brute-force search. The Random Forest, Naive Bayes, MLP, and CNN models tend to identify similar features as most important, whereas XGBoost selects a markedly different set. The former group of models favors features associated with domain categories frequently visited by a large portion of users, while XGBoost emphasizes features from more niche or rarely accessed categories. These two approaches are thus fundamentally different and potentially complementary.

All models are available for download under an open-source license at the following GitHub repository: https://github.com/morozovic/bap.

Comparison of existing and proposed solution

The best model developed by us based on CNN achieved a validation accuracy of 86.7%.

The DNSMiner solution described in5 and6 and another solution21 also achieved high accuracy. The final results achieved in all cases were strongly related to the preprocessing of the original datasets. In all cases, preprocessing the datasets significantly reduced their original volume. The preprocessing of the datasets was specific in all cases, and therefore the results achieved are not trivially comparable.

As we mentioned earlier in4, the original data sets on which all three of the above-mentioned articles are based are not freely available for download. As a result, it is not possible to make a direct comparison between our solution and the original solutions on the same data sets.

The models from5,6, and21 use DNS fingerprints created exclusively from domain names to identify specific IP addresses. The model we created is more complex and uses a set of quantitative attributes in addition to domain names. A detailed description of these attributes can also be found in4.

The advantage of our model is that it combines domain names into a constant number of categories, which guarantees the invariance of the DNS fingerprint with regard to the creation of new domains in the future. Compared to the original models, our solution also allows us to identify various attributes that are essential for understanding the principle of DNS fingerprint creation and thus explain the mechanism of its functionality.

Limitations of the proposed solution and future work

The proposed solution still has certain limitations. The first limitation is that a stable DNS fingerprint requires the use of a specific public IP address by only one user. The assumption of a unique public IP address can be easily applied to networks that prefer the more modern IPv6 protocol, as in this case each user should have their own unique public IPv6 address. For IPv4, the situation is more complicated, as NAT is very often used due to the shortage of public IPv4 addresses, combining multiple private IPv4 addresses into a single public one. As a result of using NAT, the DNS fingerprint corresponds to multiple users. DNS fingerprinting is also not well suited for public IP addresses that users only use for a short time, such as in restaurants, public transport, etc., as a stable DNS fingerprint cannot be created. Another limitation of our solution is the use of multiple DNS servers simultaneously by a single user, which also distorts the DNS fingerprint.

A possible improvement for the future could be to explore the possibility of detecting DNS fingerprints for users sharing the same public IP address or finding other fundamentally different classification features that may reflect user behavior.

Conclusion

In this paper, we investigated the feasibility of DNS-based fingerprinting of individual users based on their Internet activity. Our experimental evaluation demonstrated that deep learning methods generally outperform traditional machine learning models in terms of validation accuracy - with the notable exception of XGBoost. Interestingly, XGBoost achieved the highest training accuracy (94.5%), and its performance may scale even further as the number of input features increases.

Among all tested models, the CNN yielded the best overall results, reaching a validation accuracy of nearly 87%. Furthermore, we found that the effectiveness of neural networks can be enhanced through appropriate data transformation. Specifically, applying principal component analysis (PCA) prior to training an MLP led to improved classification performance compared to other pre-processing techniques.

An additional observation emerged from the analysis of feature importance: classification models tended to cluster into two distinct groups - those favoring features from frequently visited domain categories and those prioritizing features from less commonly accessed ones. This complementarity suggests opportunities for future hybrid approaches.

Promising directions for future research include the incorporation of time-based features such as clock flags, which have so far been underutilized despite their high potential information value. Expanding the dataset is another natural next step. Finally, it may be beneficial to design ensemble models that integrate the strengths of both model families - those that favor dominant patterns and those that detect subtle, niche behaviors.

Supplementary Information

Acknowledgements

The authors would like to acknowledge the University of South Bohemia, Faculty of Science, and Czech Technical University Faculty of Information Technology for providing the necessary technical equipment to realize experiments.

Author contributions

David Morozovič is the author of the original work creating the basis of the paper. David wrote Sections 1–5. Michal Konopa participated in the methodology and stylistics of all sections. Jan Fesl is the principal investigator of the paper idea. Jan is the author of sections 6 and 7 and co-author of section 4.

Funding

The research was financed by no external grant.

Data availability

The dataset analysed during the current study is available in the Zenodo repository, https://zenodo.org/records/10887463.

Declarations

Competing interests

The authors declare no competing interests.

Footnotes

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Supplementary Information

The online version contains supplementary material available at 10.1038/s41598-026-37631-7.

References

  • 1.Satrapa, P., & Filip, O. Domain name system (2023).
  • 2.Schwenk, J. Guide to internet cryptography10.1007/978-3-031-19439-9 (2022). [Google Scholar]
  • 3.CLOUDFLARE: Dns server types. Accessed 2025-05-07.
  • 4.Josef Zápotocký, J.F., & Fesl, J. A user dns fingerprint dataset. Data Brief54(110389). 10.1016/j.dib.2024.110389 (2024). [DOI] [PMC free article] [PubMed]
  • 5.Kim, D.W., & Zhang, J. You are how you query: Deriving behavioral fingerprints from dns traffic. In: Thuraisingham, B., Wang, X., Yegneswaran, V. (eds.) Security and Privacy in Communication Networks, pp. 348–366. Springer, Cham (2015). 10.1007/978-3-319-28865-9_19.
  • 6.Wook Kim, D., & Zhang, J. Deriving and measuring dns-based fingerprints. J. Inf. Secur. Appl.36, 32–42. 10.1016/j.jisa.2017.07.006 (2017).
  • 7.Jia, Z., & Han, Z. Research and analysis of user behavior fingerprint on security situational awareness based on dns log, 1–4. 10.1109/BESC48373.2019.8963120 (2019).
  • 8.Lai, Q., Zhou, C., Ma, H., Wu, Z., & Chen, S. Visualizing and characterizing dns lookup behaviors via log-mining. Neurocomputing169, 100–109. 10.1016/j.neucom.2014.09.099 (2015).
  • 9.Perdisci, R., Papastergiou, T., Alrawi, O., & Antonakakis, M. Iotfinder: Efficient large-scale identification of iot devices via passive dns traffic analysis, 474–489. 10.1109/EuroSP48549.2020.00037 (2020).
  • 10.Fan, C.-I., Shie, C.-H., Hsu, C.-M., Ban, T., Morikawa, T., & Takahashi, T. Iot botnet detection based on the behaviors of dns queries, 1–7 (2022). 10.1109/DSC54232.2022.9888913 . Accessed 2025-04-18.
  • 11.Singh, M., Singh, M., & Kaur, S. Detecting bot-infected machines using dns fingerprinting. Digit. Invest.28, 14–33. 10.1016/j.diin.2018.12.005 (2019).
  • 12.Alieyan, K., Almomani, A., Anbar, M., Alauthman, M., Abdullah, R., & Gupta, B. B. Dns rule-based schema to botnet detection. Enterprise Inf. Syst.15(4), 545–564. 10.1080/17517575.2019.1644673 (2021).
  • 13.Quezada, V., Astudillo-Salinas, F., Tello-Oquendo, L., & Bernal, P. Real-time bot infection detection system using dns fingerprinting and machine-learning. Comput. Netw.228, 109725. 10.1016/j.comnet.2023.109725 (2023).
  • 14.Fachkha, C., Bou-Harb, E. & Debbabi, M. Fingerprinting Internet DNS Amplification DDoS Activities10.1109/NTMS.2014.6814019 (2014). [Google Scholar]
  • 15.Mohan, H. G., Kumar, J. & Nandish, M. Host-level botnet detection via internet dns traffic analysis using neural networks. Internet Technol. Lett.8(5), 1. 10.1002/itl2.70101 (2025). [Google Scholar]
  • 16.Muhammad, A. T., Hostiadi, D. P. & Ijtihadie, R. M. Ensemble network graph-based classification for botnet detection using adaptive weighting and feature extraction. IEEE Access13, 31183–31204. 10.1109/access.2025.3541125 (2025). [Google Scholar]
  • 17.Liu, S., Fauzi, F. & Kok, V. J. A systematic literature review: Classifying iot botnet data features based on its lifecycle. IEEE Access1, 1–1. 10.1109/access.2025.3559635 (2025). [Google Scholar]
  • 18.Matsunaka, T., Yamada, A., & Kubota, A. Passive os fingerprinting by dns traffic analysis, 243–250. 10.1109/AINA.2013.119. Accessed 2025-04-20 (2013).
  • 19.Jimenez-Berenguel, A., Moure-Garrido, M., Garcia-Rubio, C., & Campo, C. Characterizing mobile applications through analysis of dns traffic, 69–76. 10.1145/3616394.3618268 (2023). Accessed 2025-04-20
  • 20.Campo, C., Garcia-Rubio, C., Jimenez-Berenguel, A., Moure-Garrido, M., Almenares, F., & Díaz- Sanchez, D. Inferring mobile applications usage from dns traffic. Ad Hoc Netw.163, 103601. 10.1016/j.adhoc.2024.103601 . Accessed 2025-04-20 (2024).
  • 21.Herrmann, D., Banse, C. & Federrath, H. Behavior-based tracking: Exploiting characteristic patterns in dns traffic. Comput. Secur.39, 17–33. 10.1016/j.cose.2013.03.012 (2013). [Google Scholar]
  • 22.Zhang, Y., Yang, M., Gu, X., Pan, P., & Ling, Z. Fingerprinting network device based on traffic analysis in high-speed network environment. In 2018 Sixth International Conference on Advanced Cloud and Big Data (CBD), pp. 249–256. 10.1109/CBD.2018.00052 (2018).
  • 23.Herrmann, D., Kirchler, M., Lindemann, J., & Kloft, M. Behavior-based tracking of internet users with semi-supervised learning, 596–599. 10.1109/PST.2016.7906992 . Accessed 2025-04-20 (2016).
  • 24.Kirchler, M., Herrmann, D., Lindemann, J., & Kloft, M. Tracked without a trace: Linking sessions of users by unsupervised learning of patterns in their dns traffic. In Proceedings of the 2016 ACM Workshop on Artificial Intelligence and Security. AISec ’16, pp. 23–34. Association for Computing Machinery, New York, NY, USA (2016). 10.1145/2996758.2996770.
  • 25.Chang, D., Chen, J.Q., Li, Z., & Li, X. Hide and seek: Revisiting dns-based user tracking. In: 2022 IEEE 7th European Symposium on Security and Privacy (EuroS &P), pp. 188–205 (2022). 10.1109/EuroSP53844.2022.00020.
  • 26.Li, H., Li, Z., Zhang, S. & Pu, X. Malicious dns detection by combining improved transformer and cnn. Sci. Rep.14, 1. 10.1038/s41598-024-81189-1 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.White, M., & Jeon, S. Using t-sne to explore misclassification, 1–4. 10.1109/URTC49097.2019.9660573. Accessed 2025-05-05 (2019).
  • 28.Kimura, M. Generalized t-sne through the lens of information geometry. IEEE Access9, 129619–129625. 10.1109/ACCESS.2021.3113397 (2021). [Google Scholar]
  • 29.Gisbrecht, A., Mokbel, B., & Hammer, B. Linear basis-function t-sne for fast nonlinear dimensionality reduction, 1–8 (2012). 10.1109/IJCNN.2012.6252809. Accessed 2025-05-05.
  • 30.Amutha, P. & Priya, R. An optimized random forest for multi class classification to classify the students using machine learning approaches. Int. J. Health Sci.6(S7), 5312–5326. 10.53730/ijhs.v6nS7.13116 (2022).
  • 31.Morys-Magiera, A., Długosz, M., & Skruch, P. Comparison of decision support models – a recruitment case study as a multiclass classification problem with limited data, 93–98. 10.1109/MMAR58394.2023.10242525. (2023).
  • 32.Pristyanto, Y., Ferdita Nugraha, A., Faticha Alfa Aziza, R., Hadi Purwanto, I., Sulistiyono, M., & Dahlan, A. Comparison of ensemble models as solutions for imbalanced class classification of datasets, 1–4. 10.1109/IMCOM56909.2023.10035615. Accessed 2025-05-06 (2023).
  • 33.Team, E.A. Accuracy, precision, and recall in multi-class classification (2025). Accessed 2025-05-10.
  • 34.Maharana, K., Mondal, S., Nemade, B.: A review: Data pre-processing and data augmentation techniques. Global Transit. Proc.3(1). 10.1016/j.gltp.2022.04.020. Accessed 2025-04-13 (2022).
  • 35.Team, D. DATAtab: Online Statistics Calculator. Accessed 2025-04-14.
  • 36.Faizi, N., & Alvi, Y. Biostatistics manual for health research, 111–112 (2023).
  • 37.Salmerón-Gómez, R., García-García, C., García-Pérez, J.: A redefined variance inflation factor: Overcoming the limitations of the variance inflation factor. Comput. Econ.65, 337–363. 10.1007/s10614-024-10575-8. Accessed 2025-04-22 (2025).
  • 38.Lundberg, S., & Lee, S.-I. A Unified Approach to Interpreting Model Predictions. https://arxiv.org/abs/1705.07874 (2017).

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Data Availability Statement

The dataset analysed during the current study is available in the Zenodo repository, https://zenodo.org/records/10887463.


Articles from Scientific Reports are provided here courtesy of Nature Publishing Group

RESOURCES