How to update DHCP with API?

I have a unique use case for this request.

Let me start out with I live out in the middle of nowhere and only have 1 option in provider for internet. Recently, I have been going over our allotment and decided to purchase another hot spot to decrease our internet cost. I am working to create a program, that when triggered, would change the gateway in piholes dhcp settings to the other router. How could I do this with the current api?

I know there is a RESTapi on the way but unfortunately it is not here right now.
https://github.com/pi-hole/FTL/pull/659/files

Any help would be appreciated.

My plan B is to get a pfsense (Netgate 1100 pfSense+ Software - VPN, Routing, & Firewall Hardware Appliance) router and have the pihole point to it and use the pfsense api to change which router the LAN is using instead of the pihole.

Thanks!!!

Let me add that I am currently using plan B with a pfsense VM inside a freenas but is to slow to deal with the network traffic. It was struggling when it was just me web browsing for answers to pihole's API.

AFIAAO, the API doesn't expose any DHCP features - Pi-hole is a filtering DNS forwarder after all.
As Pi-hole borrows its DHCP features of dnsmasq, you'd have to read and write Pi-hole's dnsmasq configuration under /etc/dnsmasq.d/ and possibly Pi-hole's configuration defaults in /etc/pihole/setupVars.conf as well. When done, you'd need to pihole restartdns.

However, changing the gateway IP in your DHCP server doesn't get that information to your clients. They will only request an update once their DHCP lease expires (which defaults to 24 hours with Pi-hole's DHCP).

Your solution to use a machine as a kind of gateway proxy that will forward requests to different gateways seems like a cleaner approach, provided that machine can handle it. It should probably feature at least two or even three network interfaces: one ethernet port receiving traffic from your network, and one dedicated port to each of your actual gateways (or one and a small switch where only your actual gateways are connected).

Another option may be to use just one router and change the authentication details for your internet connection to your second plan once the first plan's download limit nears exhaustion. I doubt your router can be scripted to do so automatically, though.

Yet another approach may be to split your usage right from the start by directing some of your clients to your second gateway.
This would have to be done by configuring dnsmasq accordingly - refer to dnsmasq documentation for details.

Doesn't sound like "performance".

Yes, this will be your problem with DHCP. You'd have to force them to refresh their leases, e.g., by power-cycling your network switch / WiFi access point. And yes, there is no Pi-hole API for this, too :slight_smile:

Bucking_Horn, I think you are right in that I should use a PFSense as a proxy gateway to complete these requirements as I also need to connect local from the cloud. I am planning on using a SG1100 to complete this task.

Thanks for the great advise and quick response!

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