LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to fully manipulate imcoming IP packet? (https://www.linuxquestions.org/questions/programming-9/how-to-fully-manipulate-imcoming-ip-packet-500277/)

zhubaining 11-10-2006 03:32 AM

How to fully manipulate imcoming IP packet?
 
I want to write a program to do something on the incoming IP packet immediately after the NIC got one, and then forward to another NIC to send it out if necessary. It is very similar to what NAT server does but I am not doing that.

Does there exist any lib or code framework help me to do this?

Any suggestion will be appreciated!

jlinkels 11-10-2006 05:19 AM

Have you looked at IP tables? It basically does filtering and manipulating of IP packets. Packets are being handled as soon as they leave the NIC. Iptables does NAT (NAT is not a server BTW), but can do much more.

More background at www.netfilter.org

jlinkels

ghostdog74 11-10-2006 07:50 AM

Ever heard of libpcap? you can use it to do what you want.

zhubaining 11-13-2006 10:43 PM

Quote:

Originally Posted by ghostdog74
Ever heard of libpcap? you can use it to do what you want.

libpcap can be used to capture incoming packets and send packets via a specified network interface, however, I learned that it only captures and is incapable of preventing the incoming packets from being passed to the protocol stack (and the application). That is to say, it cannot be used to make a firewall or NAT.

Fortunately, now I find that netfilter can take the full control of all packets on a host, thus can help me to do that...


All times are GMT -5. The time now is 03:51 PM.