setupVars.conf and Frequently Changing IP Addresses

First off, thanks for such a great product!!

I have started to build and install these. I used to have a standard image that went out with a static IP address. This works well until the router address jumps from say 192.168.0.1 to 192.168.2.1. Then, the device is offline, and I can not finish setup remotely.

My fix is to let it get a dynamic IP, and while remotely logged into their network/PC, find the pihole. SSH in, set proper static, and I'm done. I just realized on some units however I was having slow response times for blocked sites, instead of instant. I also noticed that in the web UI, the IP address showing in settings was not correct. This is because the webUI (and also gravity.list) use the same IP as is set in /etc/pihole/setupVars.conf, which never changes from initial install.

My suggestion (and this may not be practical, or may break other things, etc) - have setupVars.conf be updated on each boot, before everything else fires up, to the current IP address. The only other issue is with gravity.list. It seems that the only way to fix that is a global IP address replace or pihole -r / -g (after fixing setupVars.conf).

Any way to make this a bit more automated? If it could be - this could be portable and seamlessly moved from network to network. It is currently portable, but gets broken on DNS resolution if IP address changes and needs a few manual fixes that cannot be accomplished via web UI.

EDIT: After a bit more thinking, it seems to me that the IP address in gravity.list is not even needed - on mine, the first column is ALWAYS the current IP address of the pihole. Unless it's possible to have different IP addresses for different blocked sites, it seems redundant. Couldn't the process reading gravity.list always pull the current IP address instead?

Manually, this seems to do it:

newip=ifconfig|grep broad|awk -F' ' '{print $2}'
oldip=grep IPV4 /etc/pihole/setupVars.conf |awk -F= '{print $2}'|awk -F/ '{print $1}'
sudo sed -i.bak 's/'"$oldip"'/'"$newip"'/g' /etc/pihole/setupVars.conf
oldip=head -1 /etc/pihole/gravity.list|awk -F' ' '{print $1}'
sudo sed -i.bak 's/'"$oldip"'/'"$newip"'/g' /etc/pihole/gravity.list
pihole restartdns

How do you update the clients with the new IP address of the DNS Pi-hole server?

Pi-hole tries to set itself up to have a static IP address, so assuming your network does not jump around it should be fine. That being said, you said your router regularly jumps around to different subnets. Either you have a large netmask, or your router is configured incorrectly. It should not be changing subnets, and the IP address should be static.

For gravity.list, the current stable version has it in HOSTS format which requires that it have the IP address on the left. In the FTLDNS beta, we've made it only contain the domains.

I understand that Pi-hole sets itself up as static, and needs to be that way. I'm trying to take that 'static' configuration and move it to a different network. I want to have a standard pi-hole image, that I can throw on a Pi Zero and hand to a friend. At this point, it cannot be static. If their network is different (explained below) there are problems.

When I say 'network or router jumps around' - this is because I'm installing the same pihole image in several different network environments (I'm not your typical end user). I have it set to dynamic ip address for the previously mentioned reasons. So, on my network, my router is 192.168.0.1. My pihole device works great. If I clone that device and give it to a friend, and their router is 192.168.2.1, gravity.list will still have it's addresses starting with 192.168.0.*. Each blocked domain will timeout, rather than immediately be piholed.

All of this can be fixed by repairing pihole once in the new environment - I just see a way to make this automatic and very portable (as this has been my rigorous testing in the last 2 weeks).

As far as having the IP address in the left - I had a feeling it had to do with hosts format. Any way to simply ignore the entry, and still pull the current IP?

Thanks for your time.

Dan - with the commands I posted. Those do the trick. I think just repairing pi-hole also does the same. I'm trying to automate this behavior - hopefully my other post makes it clear.

This is a feature request then, because we do not currently support this use case.

If you think this is a possibility, I will submit a feature request. I think it would be great to be able to have a Pi-Hole device @ home, and then take it to the hotel if you want. As far as I'm concerned, this is almost there, just needs a few more things.

Thanks for listening.

It is not a priority, unless a lot of users vote that they want it. We're focusing on FTLDNS, new web interface, the API, and providing support right now.

Please open this as a feature request. I can see the utility of it and I'd like to keep this tracked for future implementation.