[SOLVED] Pi-hole on Amazon EC2 not filtering ads

There is no trace in /etc:

[root@ip-172-31-7-138 ~]# ag 172.31.0.2 /etc
[root@ip-172-31-7-138 ~]# 

I've tweeted the creator of the Arch Linux image for EC2.

How is the IP configured on this EC2 VM ? Is it static or acquired through DHCP ?

Is dhcpcd5 installed ?

apt-cache policy dhcpcd5

Whats in the dhcpcd.conf file ?

grep -v '#\|^$' /etc/dhcpcd.conf

If no static IP details are set in dhcpcd.conf, you could try add below two lines at the end of the dhcpcd.conf file and reboot to check:

nohook resolv.conf
static domain_name_servers=127.0.0.1

Ohw ps. all these options are described on the man page if dhcpcd5 is installed:

man dhcpcd.conf

EDIT: Not sure about the nohook so also try without the 'nohook resolv.conf'.

I've updated my /etc/dhcpcd.conf file in this way:

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
noipv4ll

# Disable ARP probes, allows us to take our lease sooner.
noarp

nohook resolv.conf
static domain_name_servers=127.0.0.1

[root@ip-172-31-7-138 ~]# 

restarted the whole vm but still getting nameserver 172.31.0.2 in my /etc/resolv.conf

Looks like the VM is set to acquire IP details etc via DHCP.
Try only below one:

nohook resolv.conf

And manually edit resolv.conf to have only 127.0.0.1 as nameserver.
See if that survives a reboot.

EDIT: or one could remove the "option domain_name_servers" from dhcpcd.conf to prevent resolv.conf from being overwritten by the DHCP process.

I solved by editing the files in /etc/systemd/network folder by setting UseDNS=no.

1 Like

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