Debian 11 with pihole : network configuration information

Hello everyone,

I have debian 11 with static ip configured by hand as you see.

cat /etc/network/interfaces

source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback

auto enp88s0
iface enp88s0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 127.0.0.1

I have also configured the resolv.conf in this way

cat /etc/resolv.conf

nameserver 127.0.0.1

cat /etc/hosts

127.0.0.1 localhost
127.0.1.1 pihole.pihole pihole

::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

I wanted to ask you if it is correct or if there is a better method.

thanks

Configuring IP details in /etc/network/interfaces.d/ is depreciated.
You should configure IP details in your network manager that is applied for your distro:

pi@ph5b:~ $ lsb_release -d
Description:    Raspbian GNU/Linux 11 (bullseye)
pi@ph5b:~ $ apt policy dhcpcd5 network-manager netplan connman
dhcpcd5:
  Installed: 1:8.1.2-1+rpt5
  Candidate: 1:8.1.2-1+rpt5
  Version table:
 *** 1:8.1.2-1+rpt5 500
        500 http://archive.raspberrypi.org/debian bullseye/main armhf Packages
        100 /var/lib/dpkg/status
     7.1.0-2 500
        500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages
network-manager:
  Installed: (none)
  Candidate: 1.30.0-2
  Version table:
     1.30.0-2 500
        500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages
netplan:
  Installed: (none)
  Candidate: 1.10.1-5
  Version table:
     1.10.1-5 500
        500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages
connman:
  Installed: (none)
  Candidate: 1.36-2.2
  Version table:
     1.36-2.2 500
        500 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages

lsb_release -d

Description: Debian GNU/Linux 11 (bullseye)

apt policy dhcpcd5 network-manager netplan connman

dhcpcd5:
  Installato: (nessuno)
  Candidato:  7.1.0-2+b1
  Tabella versione:
     7.1.0-2+b1 500
        500 http://deb.debian.org/debian bullseye/main amd64 Packages
network-manager:
  Installato: (nessuno)
  Candidato:  1.30.0-2
  Tabella versione:
     1.30.0-2 500
        500 http://deb.debian.org/debian bullseye/main amd64 Packages
netplan:
  Installato: (nessuno)
  Candidato:  (nessuno)
  Tabella versione:
connman:
  Installato: (nessuno)
  Candidato:  1.36-2.2
  Tabella versione:
     1.36-2.2 500
        500 http://deb.debian.org/debian bullseye/main amd64 Packages

in all the researches made on the web they always talk about modifying the interfaces file.

At this point I ask, with debian 11 (amd64) and pihole how exactly should the network interface and the nameserver be configured?

thanks

Thats weird.
I have a Debian laptop (with desktop though):

dehakkelaar@laptop:~$ lsb_release -d
Description:    Debian GNU/Linux 11 (bullseye)

And network-manager is the default NM for it:

dehakkelaar@laptop:~$ apt policy dhcpcd5 network-manager netplan connman
dhcpcd5:
  Installed: (none)
  Candidate: 7.1.0-2+b1
  Version table:
     7.1.0-2+b1 500
        500 http://ftp.nl.debian.org/debian bullseye/main amd64 Packages
network-manager:
  Installed: 1.30.0-2
  Candidate: 1.30.0-2
  Version table:
 *** 1.30.0-2 500
        500 http://ftp.nl.debian.org/debian bullseye/main amd64 Packages
        100 /var/lib/dpkg/status
netplan:
  Installed: (none)
  Candidate: (none)
  Version table:
connman:
  Installed: (none)
  Candidate: 1.36-2.2
  Version table:
     1.36-2.2 500
        500 http://ftp.nl.debian.org/debian bullseye/main amd64 Packages

You can try search for anything that resembles a NM with below:

systemctl

If certain no NM is installed and active, then /etc/network/interfaces would be the right place.
Just as long as the ifupdown package is installed:

dehakkelaar@laptop:~$ apt policy ifupdown
ifupdown:
  Installed: 0.8.36
[..]
dehakkelaar@laptop:~$ apt show ifupdown
[..]
Description: high level tools to configure network interfaces
 This package provides the tools ifup and ifdown which may be used to
 configure (or, respectively, deconfigure) network interfaces based on
 interface definitions in the file /etc/network/interfaces.
dehakkelaar@laptop:~# systemctl status ifupdown-pre.service
[..]
     Active: active (exited) since Fri 2021-12-31 11:37:07 CET; 3 months 4 days ago

And it does what it promises:

dehakkelaar@laptop:~$ dpkg -L ifupdown
[..]
/sbin/ifup
dehakkelaar@laptop:~$ man ifup
[..]
DESCRIPTION
       The  ifup  and  ifdown  commands  may be used to configure (or, respec‐
       tively, deconfigure) network interfaces based on interface  definitions
       in  the  file  /etc/network/interfaces.  ifquery command may be used to
       parse interfaces configuration.

For Debian 11 on my RPi I just followed the Debian wiki and it works fine (appears you have done the same).

https://wiki.debian.org/NetworkConfiguration

Your question is about networking in general, not about Pi-hole.

You should consider to also consult documentation and support for your chosen OS and network management tool.

That said, I'll just add my two cents to the answers anyway, and finish that with some generic information about what Pi-hole requires.

I guess whatever works also is correct for you.

deHakkelaar is right to point out that you should consider your OS's respective network manager - not so much because /etc/network/interfaces.d/ won't work anymore, but more to avoid unexplicable behaviour or outright conflicts with your system's preferred network management tool.

Debian introduced alternative ways for network configuraton when they adopted systemd (that was way back with Debian Jessie, I think). It doesn't help that not all Debian-based distributions use the same, and it only adds to the confusion that bits of older documentation and recommendation are still floating around everywhere on the net.

For Debian itself, in addition to the docs NGr linked, you'd also find documentation on the systemd-networkd/NetworkManager way of network configuration on systems with or without a GUI from Debian at Chapter 5. Network setup, with a list of appropriate tools.

In general, your hosting machine requires a stable IP address to run Pi-hole, independently of how you actually ensure that.

You don't necessarily have to manually configure a static IP address on-device (by whichever OS and network tools you see fit).
You could also opt to configure a DHCP lease reservation (aka fixed or static IP address) for your Pi-hole host's MAC address in your router.

While either approach is sufficient, a static on-device IP would be preferable if you'd plan to run Pi-hole as your DHCP server.

2 Likes

I was looking for the right word and depreciated was the wrong one I notice now.
What Debian image/install/download URL did you install that came without any NM?

it's the netinst https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-11.3.0-amd64-netinst.iso

1 Like

Who say that? Debian server images come with ifupdown only, so /etc/network/interfaces(.d) is the only way to configure a network OOTB, and it is the by far best integrated way with many other network related software optionally hooking themselves into ifup/ifdown tasks. All other network managers IMO are just an overkill for applying a simple static IP. So the exactly best and simple method to apply a static IP on Debian.

One note: dns-nameservers is used by resolvconf to apply static nameservers to /etc/resolv.conf. If you do not have resolvconf installed, dns-nameservers is ignored and can be removed. If you use resolvconf, you shouldn't edit /etc/resolv.conf (which would be a symlink then) directly instead, since resolvconf does and overwrites it anyway.

1 Like

Thanks for pointing out my mistake ... again :wink:
Last Debian lite/minimalistic install for me was a while back with Stretch.
After that, I did some lite installs with TinkerOS (Tinkerboard) and Armbian (Odroid) and noticed both came with their own NM same as Pi-OS making me believe they all abandoned good old trusty ifupdown for the IP assigning.

I still have not found a good explanation why they come with a NM if they advertise it to be a lite/minimalistic install.
Most all of those NM's are a bit awkward/difficult to configure IP aliasing, bridging, bonding or power saving (like we found out already).
If it were to me, they should not provide any NM besides ifupdown if they advertise their distro to be lite/minimalistic.

OOT discussion

NetworkManager AFAIK is better integrated into desktops, probably Armbian simply wanted to have a single tool for all images, but not sure. Yeah, I mean I develop DietPi, which has ~half the image size compared to Armbian's server images. Armbian's "minimal" images come closer, but they are not built regularly for all SBCs, and they lack major features, i.e. things we do pre-install on DietPi as IOO mandatory for bootstrapping a server system. So those Armbian "minimal" images are more developer images, not so much "server" images. Different priorities when it's about how far a minimal/server image should be really minimal :slightly_smiling_face:.

Raspberry Pi OS (previously "Raspbian") ships with dhcpcd form the very beginning, as their DHCP client of choice (isc-dhcp-client would have been the ifupdown integrated alternative). And of course it makes sense to ship images with a DHCP client so that in most cases they have Internet access OOTB. But while most guides around the web suggest to configure dhcpcd to assign a static IP on Raspberry Pi, this is actually not documented on any official RPi docs to be the intended method. I never understood the idea why one would use a DHCP client to assign a static IP, especially on Raspberry Pi OS which does ship with ifupdown, related ifup@.service udev rules and networking.service enabled OOTB, and adding and iface eth0 inet static definition to /etc/network/interfaces(.d) makes dhcpcd ignoring this interface automatically.

Ubuntu uses systemd-networkd + systemd-resolved, but they are not as flexible as ifupdown from what I found, also also run two 24/7 processes for only static IPs. On Debian's debconf (Debian Conference) I remember a short discussion on whether Debian should follow Ubuntu and switch from ifupdown to systemd-networkd + systemd-resolved, but they didn't found any reason to do so either, and another argument was that further relying on systemd makes SysV (or other init system) users unhappy :slightly_smiling_face:.

@fatez
Further suggestions:

address 192.168.1.100
netmask 255.255.255.0

=>

address 192.168.1.100/24

The netmask option really is deprecated in favour of adding CIDR notation to the address option: interfaces(5) — ifupdown — Debian bullseye — Debian Manpages

And also:

auto lo
iface lo inet loopback

This is redundant, since ifup sets up the loopback interface automatically. Indirectly documented here (--no-loopback): ifup(8) — ifupdown — Debian bullseye — Debian Manpages

1 Like

Another thing that looks weird is below FQDN pihole.pihole:

Usually you configure the FQDN to be the hostname plus the DNS search/suffix domain like below:

EDIT:

pi@ph5b:~ $ man hostname
[..]
       -f, --fqdn, --long
              Display  the  FQDN  (Fully  Qualified Domain Name). A FQDN
              consists of a short host name and the DNS domain name. Un‐
              less  you  are  using bind or NIS for host lookups you can
              change the FQDN and the DNS domain name (which is part  of
              the FQDN) in the /etc/hosts file. See the warnings in sec‐
              tion THE FQDN above und use hostname  --all-fqdns  instead
              wherever possible.

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