How to create a wifi to ethernet adapter via python?

I’m trying to turn a WIFI to ethernet bridge with my raspberry pi 3b+, however I also would like to intercept some of the network traffic, possibly preform some checks on the traffic, and redirect if needed with my python script. I found this article here on how to do a direct Wi-Fi to ethernet bridge, but how would I go about setting up the bridge with a python script in between?

enter image description here


in my opinion, the project should be divided into 2 parts:

  • creation of a dhcp server on eth0 with a redirect from (wlan). this is done easily with packages like dnsmasq and an iptable rule. a complete tutorial: (for information: wlan =wifi, eth0 = ethernet).

  • Then, to analyze the traffic, you’ll have to make your own DNS server (because intercepting https traffic is (almost) impossible). you won’t get the content of the request (nor the answer) but you’ll get the url of the request.
    Making your own dns seems complicated, however, by installing pi-hole ( (dns server for raspberry), you can then make python scripts that uses on the pi-hole api (in order to block and redirect requests). Either with command lines directly, or with a library like

Is everything clear ?