The issue I am facing: How do I access and change my Pi-hole interface if I've changed my IP?
Details about my system: I'm trying to use Pi-hole on a Raspberry Pi 4b running Raspberry Pi OS 64-bit behind a Protectli firewall running pfSense.
What I have changed since installing Pi-hole: I just set up Pi-hole a couple months ago and used the IP 192.168.0.33 but have since changed the connected network's static IP and I don't know how to update Pi-hole's IP. I can verify that the my network is set up properly and I have internet access.
I still have access to the original router (the ISP router) although I plan on using Pi-hole on one of the firewall's networks (which has the altered static IP).
If you are able to ssh in to the Pi-hole you can run the command pihole -r and select Reconfigure and give it the new settings including the new router IP.
Just to confirm, the Pi in the photos is a different one to the Pi-hole Pi?
The Pi-hole was originally on the 192.168.0.x network (at .33), and the router would have also been on that network (probably at .1 or .254).
This terminal that you are on is on 192.168.174.101 and the router's IP is 192.168.174.1. These are both on the 192.168.174.x network so they will not be able to reach anything on the Pi-hole's network.
May I ask, why did you change the router's static IP? Was it a replacement unit that had this new IP? Or is it the same router and you changed it yourself in the router settings? If so, did you intend to change that 0 to 174? If it's a new router, is the Pi-hole connected via ethernet or is it connected via wifi? If it's wifi then those settings might need to change too.
Did the Pi-hole have a statically configured IP in its setup, or was it getting its address via DHCP and you had an IP address reservation in your router?
If you can answer these, plus any extra info you think might be relevant, that should help form a plan to get your Pi-hole back in use.
I originally set up Pi-hole with my ISP's router. This time around though, I'm trying to set it up with one of pfSense's networks (I want to have network segregation from IoT devices & visitors from my personal network). I did intentionally change my firewall's static IP address to add a little obscurity for security. I don't have access to change my ISP router's IP so I never could set a static IP to it to apply to the Pi-hole.
I currently have the Raspberry plugged into the firewall via Ethernet but I can plug it into my ISP's router if needed.
One hack that might be quick... your pfSense network is on 192.168.174.0/24, ie a subnet mask of 255.255.255.0. Can you temporarily change the subnet mask to a /16, ie 255.255.0.0 and rejoin your network with your current terminal?
That would make the Pi-hole reachable directly at its old address on 192.168.0.33. Then you can ssh in run the reconfigure as per the first reply. You would give it the IP settings you want it to have on your normal pfSense network (ie with the normal subnet mask).
Then return your pfSense network subnet mask back to normal and reconnect your terminal, and you should find the Pi-hole reachable at its newly configured address.
Question for anyone who knows – when you do a pihole -r Reconfigure, does it accept all the new settings first and prepare everything ready, but not apply them until after it is rebooted?
If so then a cleaner way would be to plug the Pi-hole and a client into the original ISP router (since @Pi-Eater has confirmed that is still available). This would make it reachable from that client on its original address, where it can then be ssh'd into and reconfigured, safe in the knowledge that it won't suddenly drop off part way through.
pi@ph5a:~ $ less /usr/local/bin/pihole
[..]
reconfigurePiholeFunc() {
if [ -n "${DOCKER_VERSION}" ]; then
unsupportedFunc
else
/etc/.pihole/automated\ install/basic-install.sh --reconfigure
exit 0;
fi
}
pi@ph5a:~ $ less "/etc/.pihole/automated install/basic-install.sh"
[..]
# Configure networking via dhcpcd
setDHCPCD() {
# Regex for matching a non-commented static ip address setting
local regex="^[ \t]*static ip_address[ \t]*=[ \t]*${IPV4_ADDRESS}"
# Check if static IP is already set in file
if grep -q "${regex}" /etc/dhcpcd.conf; then
printf " %b Static IP already configured\\n" "${INFO}"
# If it's not,
else
# we can append these lines to dhcpcd.conf to enable a static IP
echo "interface ${PIHOLE_INTERFACE}
static ip_address=${IPV4_ADDRESS}
static routers=${IPv4gw}
static domain_name_servers=${PIHOLE_DNS_1} ${PIHOLE_DNS_2}" | tee -a /etc/dhcpcd.conf >/dev/null
# Then use the ip command to immediately set the new address
ip addr replace dev "${PIHOLE_INTERFACE}" "${IPV4_ADDRESS}"
# Also give a warning that the user may need to reboot their system
printf " %b Set IP address to %s\\n" "${TICK}" "${IPV4_ADDRESS%/*}"
printf " %b You may need to restart after the install is complete\\n" "${INFO}"
fi
}
We need to just get rid of the whole IP stack modification code. I can see how this code section would create multiple configuration stanzas by appending a new static IP address without removing the previous static IP address. The only thing it really checks for is if the new IP address is already set statically, which isn't enough.
It's time for everyone to set their networking externally apart from Pi-hole, there's more than enough documentation on the net to guide people, and more than enough variation in how every distribution has decided to handle networking to make covering cases not worth the effort and maintenance burden.
I agree. dhcpcd is mostly only applied by Raspbian/Pi-OS to my knowledge.
And they have below to configure a static IP etc:
sudo raspi-config
Plus its confusing that Pi-hole would set IP details for dhcpcd only but not for any others like network-manager, connmand, systemd-networkd, (EDIT: or old school ifupdown) etc.
I tried changing the network's IP address to /16 but got the error from this screenshot. I don't know how to get around this. I do recall seeing a section for the subnet mask addresses but I don't remember where that was located. In either case, I'm not sure if attempting to change it would return the same error message.
Would it be simpler to reninstall Pi-hole and set everything up right this time?
There seems to be no static IP set which is good for now.
Run below tool and select "Reconfigure" which will allow you to set a static IP ... if I remember correctly:
pihole -r
Afterwards, validate with below same command again (an interface section/stanza should have been added):
I just now checked and couldn't find.
Must have been confusing with other SBC distros (TinkerOS, Armbian, Xbian) which have similar configuration tools and for some I know for sure you can set a static IP.
But its indeed well documented how to set a static IP for Pi-OS/Raspbian:
That command seems like it'll do the trick but I've got a question first.
Currently the only way of accessing that target IoT network is through one Ethernet port since I don't have a router nor Ethernet switch hooked up to it. That port is currently being used by a smart TV.
If I set a static IP address on the Raspberry Pi, will I still be able to connect to a different network wirelessly until I buy an Ethernet switch for the IoT network?
Do you mean you want to connect both the wired and WiFi interfaces on the Raspi simultaneously?
If so, yes you can as long as they have different IP's assigned to them.
EDIT: Ow I think for Wifi its best to do that via below: