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

#1

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 192.168.1.2/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.4.55/24 brd 192.168.4.255 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 https://install.pi-hole.net | bash
curl: (6) Could not resolve host: install.pi-hole.net

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!

#2

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=10.0.0.2/24
  static routers=10.0.0.1
  static domain_name_servers=127.0.0.1

interface eth0.0
  static ip_address=192.168.1.99/24

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 127.0.0.1/8 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 10.0.0.2/24 brd 10.0.0.255 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 192.168.1.99/24 brd 192.168.1.255 scope global eth0.0
       valid_lft forever preferred_lft forever

pi@noads:~ $ ip -4 r
default via 10.0.0.1 dev eth0 src 10.0.0.2 metric 202
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.2 metric 202
192.168.1.0/24 dev eth0.0 proto kernel scope link src 192.168.1.99 metric 203

The two IP addresses are residing in different subnets 192.168.1.0/24 and 192.168.4.0/24.
A device living in the 192.168.1.0/24 subnet wont be able to communicate with devices in the 192.168.4.0/24 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 8.8.8.8' | sudo tee /etc/resolv.conf

And run install again:

curl -sSL https://install.pi-hole.net | 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
#3

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

1 Like