Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
According to a document at linuxjournal (see below) it should be possible to receive packets at a very low level.
Quote:
"In recent versions of the Linux kernel (post-2.0 releases) a new protocol family has been introduced, named PF_PACKET. This family allows an application to send and receive packets dealing directly with the network card driver, thus avoiding the usual protocol stack-handling (e.g., IP/TCP or IP/UDP processing). That is, any packet sent through the socket will be directly passed to the Ethernet interface, and any packet received through the interface will be directly passed to the application." http://www.linuxjournal.com/article/4659
Our question is now if it could be possible to hijack the packets that matches our filter. The packets should NOT be processed further by the stack in Linux.
Our question is now if it could be possible to hijack the packets that matches our filter. The packets should NOT be processed further by the stack in Linux.
I think the key issue there is the last bit, not being processed further by the stack. You can use PF_PACKET to read inbound packets as they fly by, and inject packets for output, (see the pcap(3) man page), but as far as I know there is no mechanism within that protocol to halt further processing of inbound packets. You're getting a copy of the data, rather than the one and only instance.
If you want complete control, I think what you'll need to look at instead is the iptables NFQUEUE target. This causes matching packets to be sent to a userspace daemon, which can then do whatever it wants and send back a DROP. Alternatively, I think if you have no daemon registered, the packet will just vanish into the void, but you should test that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.