Setup a Pihole and Yacy on same server guide (Linux)

Pihole and Yacy on same server

apt install curl

curl -sSL | bash

pihole -a -p

The cache size is set in /etc/dnsmasq.d/01-pihole.conf. However, note that this setting does not survive Pi-hole updates. If you want to change the cache size permanently, add a setting

nano /etc/dnsmasq.d/01-pihole.conf


nano /etc/pihole/setupVars.conf 

run pihole -r (Repair) to get the cache size changed for you automatically.

nano /etc/pihole/setupVars.conf


Set load rate limit 0 0

Sets 2 GB swap

swapoff -a

dd if=/dev/zero of=/swapfile count=2 bs=1G

mkswap /swapfile

chmod 0600 /swapfile

swapon /swapfile

swapon --show  
You need Java 11 or later to run YaCy and ant to build YaCy. This would install the requirements on debian:
sudo apt-get install ant git

git config --global core.compression 0

To use the Corretto Apt repositories on Debian-based systems, such as Ubuntu, import the Corretto public key and then add the repository to the system list by using the following commands:

apt install gnupg && sudo apt install gnupg1

wget -O - | sudo gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] stable main" | sudo tee /etc/apt/sources.list.d/corretto.list

After the repo has been added, you can install Corretto 17 by running this command:

sudo apt-get update; sudo apt-get install -y java-17-amazon-corretto-jdk

Then clone the repository and build the application:

git clone --depth 1
cd yacy_search_server
ant clean all

To start YaCy, run


Set yacy's admin passwd

nano /etc/resolv.conf


does not survive reboot but works.

Open the systemd-resolved configuration file for editing using a text editor like nano or vi. On most systems, this file is located at /etc/systemd/resolved.conf. You may need superuser privileges to edit this file, so use sudo:

sudo nano /etc/systemd/resolved.conf
Add the Nameserver:

In the configuration file, you can specify the DNS servers using the DNS directive. If the directive does not exist, you can add it. If it already exists, you can append additional DNS servers to it.


After editing the configuration file, you should restart the systemd-resolved service for the changes to take effect:

sudo systemctl restart systemd-resolved

Verify the Changes:

You can verify that your custom nameservers are in use by querying systemd-resolved for DNS information. Use the systemd-resolve command to check:

sudo resolvectl status

Test with dig

; <<>> DiG 9.18.24-1-Debian <<>> ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31688 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ; IN A


;; Query time: 160 msec ;; SERVER: (UDP) ;; WHEN: Wed Mar 13 11:06:26 UTC 2024 ;; MSG SIZE rcvd: 53

Optional settings

nano /etc/sysctl.conf

net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.core.netdev_max_backlog = 5000
net.ipv4.tcp_max_syn_backlog = 2048
net.core.somaxconn = 2048
net.ipv4.ip_local_port_range = 10000 65535
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_syncookies = 0
#net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_keepalive_time = 890
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 20

vm.swappiness = 10

sysctl -p

A blocklist I am trying its big 75 million.

Manual download to store on pihole’s web server

Enter in adlists

Setup time including Debian 12 about 1.5 hours.

Possible Fix for random DNS lookups.

sudo apt update

Next, download and install VirtualBox by running:

sudo apt install virtualbox

Step 2: Install the VirtualBox Extension Pack.

The Extension Pack provides additional features and support for USB 2.0 and USB 3.0 devices, VirtualBox Remote Desktop Protocol (VRDP) support, Disk encryption, Intel PXE boot ROM, etc.

To install the VirtualBox Extension Pack, take the following steps:

  1. Run the command:
sudo apt install virtualbox-ext-pack