Wifi HotSpot: how to allow access to only few website?

Good morning, I found this project only a few days ago and I’m already converting every raspberry I have at home. I created an access point with Raspberry 3B and it works great! Now I would like to be able to check and block some websites accessible from the access point. More precisely, I would like to leave only 2 or 3 websites accessible to those who connect to the access point left without a password. I searched online, but I would like to be sure that it works well with the hotspot created with Dietpi.
Thank you for any help and advice.

Massimo

Real quick googling

https://superuser.com/questions/357890/how-to-block-sites-with-iptables

https://serverfault.com/questions/218707/iptables-rules-to-allow-http-traffic-to-one-domain-only

https://www.tecmint.com/linux-iptables-firewall-rules-examples-commands/

Other than that…not sure


Couple easy configurators
http://phpfwgen.sourceforge.net/
http://www.mista.nu/iptables/

I also vote for iptables. You need to read a bid how to configure the rules accordingly to block all outgoing/forwarded access but just these few. Also it would be great of course if this only applies for the clients connected to the hotspot, not the RPi itself. So filtering should be done on the AP interface.

Use /etc/network/if-pre-up.d/ (maybe it needs to be if-post-up.d, not sure) to automatically load the rules on boot/network start.

I will try.
Thanks