Can I install Pi-hole on my existing Web server?

Please follow the below template, it will help us to help you!

Hello, thanks for reading my question.
I was wondering if I can install Pi-hole on my existing Web server pi.

I read this blog, and it seems like it is possible to place pi-hole as primary static IP and web server as a secondary IP (vice versa too but seems like I needed to install pi-hole first). Because my pi’s static ip is already configured to use Web Server. I am wondering if I can still set up Pi-hole after I already define pi’s primary ip.

Here is my primary and secondary ip and I am running the web server with the primary:

    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet brd scope global eth0:1
       valid_lft forever preferred_lft forever

After I set up the secondary IP, I ran the install command and I’ve got this error:

pi@cloe:~ $ curl -sSL | bash
curl: (6) Could not resolve host:

I guessed this error has happened because of ip is already reversed… What do you think? is it total impossible way? or do I miss something?

Thank you for your help!

Yes you can depending on what other web daemon you have running now ?

Looks like the blogger is not taking into account that Pi-hole will install the dhcpcd5 software package that deals with network settings and applying them.
Configuring the /etc/network/interfaces file manually will conflict with dhcpcd5:

pi@noads:~ $ apt show dhcpcd5
Description: DHCPv4, IPv6RA and DHCPv6 client with IPv4LL support
 dhcpcd is a one stop network management daemon which includes
  * RFC compliant DHCPv4 and DHCPv6 clients
  * DHCPv6 Prefix Delegation support
  * IPv4LL (aka ZeroConf) support
  * ARP address conflict resolution
  * Link carrier detection
  * Wireless SSID profiles
  * ARP ping profiles

After Pi-hole is installed better use IP aliasing like below that will give you an additional virtual interface eth0.0 :

pi@noads:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

auto eth0.0
iface eth0.0 inet manual

pi@noads:~ $ tail /etc/dhcpcd.conf
#fallback static_eth0

interface eth0
  static ip_address=
  static routers=
  static domain_name_servers=

interface eth0.0
  static ip_address=

pi@noads:~ $ sudo service networking restart
pi@noads:~ $

pi@noads:~ $ ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
3: eth0.0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet brd scope global eth0.0
       valid_lft forever preferred_lft forever

pi@noads:~ $ ip -4 r
default via dev eth0 src metric 202 dev eth0 proto kernel scope link src metric 202 dev eth0.0 proto kernel scope link src metric 203

The two IP addresses are residing in different subnets and
A device living in the subnet wont be able to communicate with devices in the subnet without a router between them.

If lucky and not having a misconfigured network (like no default gateway or routes), try run below one first:

echo 'nameserver' | sudo tee /etc/resolv.conf

And run install again:

curl -sSL | bash -x

If not lucky, you’ll have to check IP’s:

ip a

And routes:

ip r

And fix those first.

EDIT: added routes output
EDIT: some more :wink:

1 Like

Wow, It solved my problem, THANKS SO MUCH! appreciate your time and cleverness:smiley:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.