Do you really need to do this?
I understand that some people (including me) doesn’t want to buy american Products, but to block all Websites that are not European, is firstly simple not possible (so many websites are hosted in the US), the easier way were to stop using the Internet. Secondly there are so many companys that are Open Source, sustainable, etc. and not located in the EU. Just think about Pixelfed, Mozilla and Futo
You don’t/can’t.
How do you define a US website? Using IP space registered in the US? Well that pretty much blocks all sites behind a content delivery networks. Including some Lemmy instances
A domain registered to a US address? What do you do with DNS privacy?
you’re going to be blocking a lot, even franceinfo and others rely on akamai and aws
You can use flagfox to avoid the american websites.
Flagfox is a privacy nightmare, since it sends all the URLs you visit to a remote server. Use Server Status instead. It downloads a GeoIP database and stores it in your browser, and performs the lookups locally.
CDNs and distrubuted clouds make flagfox unreliable for most large sites.
Do you have a dedicated firewall that you wholly control and are comfortable messing with?
If it’s not the cheapest ISP-issued PoS then it very possibly has geo-blocking options. There are ways to know if an IP is commercial or residential but I don’t remember that off the top of my head. Anyway, you’d want to block all commercial IPs outside of Europe.
You can use a geoip service and get a list of all IPs and block everything that isn’t there in your firewall. Something like opnsense.