I am creating a network bridge that connects two Ethernet cards on the same machine. One of the cards is connected to the local network, and the other to the network device. It looks something like this:

I sniff the packages on both interfaces and then send them to others using sendp(x,iface='eth0') for the package that I sniffed on eth1 and vice versa.
I checked the packets on both interfaces and found them correct, but for some reason I can not get the IP address for the device. Below is a snippet of my code, I create two threads, one for each interface:
from scapy.all import* **THREAD1:** pkt=sniff(iface="eth0",store=1,count=1) outbuff=[] outbuff+=pkt[:] for src in outbuff[:] srcmac=src.sprintf(r"%Ether.src%") if srcmac==deviceMAC: pass else: sendp(self.outbuff[:],iface="eth1",verbose=0) **THREAD2:** pkt=sniff(iface="eth1",store=1,count=1) outbuff=[] outbuff+=pkt[:] for src in outbuff[:] srcmac=src.sprintf(r"%Ether.src%") if srcmac==deviceMAC: sendp(self.outbuff[:],iface="eth1",verbose=0) else: pass
Can someone help me with a problem or suggest me an alternative solution for this implementation?
SOLUTION: Combining Python + IPTABLES and using TRIGGER principles solves this problem.
python network-programming scapy
Abhinav
source share