LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-10-2006, 03:32 AM   #1
zhubaining
LQ Newbie
 
Registered: Aug 2005
Posts: 12

Rep: Reputation: 0
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!

Last edited by zhubaining; 11-10-2006 at 03:51 AM.
 
Old 11-10-2006, 05:19 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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
 
Old 11-10-2006, 07:50 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Ever heard of libpcap? you can use it to do what you want.
 
Old 11-13-2006, 10:43 PM   #4
zhubaining
LQ Newbie
 
Registered: Aug 2005
Posts: 12

Original Poster
Rep: Reputation: 0
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Packet Filter to redirect a packet to a user level process akawale Linux - Networking 3 09-01-2006 12:06 PM
how do i read the data in the packet that i have captured after packet capture? gajaykrishnan Programming 23 04-19-2006 05:09 AM
dump packet data to file, but no packet header Nathanael Linux - Networking 3 02-08-2006 10:27 AM
manipulate the floppy bruse Mandriva 1 02-22-2005 07:49 AM
need to manipulate dates clsonnt Programming 5 08-19-2003 10:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration