I need to inject some L2 packets(customized) to an specific interface as incoming packets in Linux to test some applications running on it.
Is there any libraries(python preferred)/examples that can help? I was skimming through the Scrapy library, but then it looks like it can only inject packets to the network as outgoing packets?
If you have the native linux
bridgemodule available then you can use it in this way. Create a bridgeNow create a virtual
ethpair (default namesveth0,veth1). veths are connected L2 devicesNow add your specific interface, lets say
eth0, and one side of thevethpair to this bridge.This adds both these interfaces to the bridge. Now when you send traffic on
veth0, you should be able to get it oneth0also(based on normal L2 switch functionality). To send traffic onveth0you simply need to pump traffic intoveth1since both of them are connected internally. So lets say you want to usetcpreplay, just doLet us know how it goes