Linux - Networking This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-25-2006, 02:27 PM
|
#1
|
LQ Newbie
Registered: Mar 2006
Posts: 6
Rep:
|
netfilter hook forward packets
Hi all,
I'm writing a simple netfilter hook module to redirect the traffic thru a tunnel between 2 machines (B and C)
Assume that i dont want to config netfilter/iptable to do anything.
The path looks like:
A-----B-------C----D
Assume on A, i add a route to forward packet (from A<->D) to B
and on D, i add a route to forward packet (from A<->D) to C
My module will be running on machines B and C.
Here are the steps what i do in my module (running on B and C)
On machine B:
1. capture packet at NF_IP_PRE_ROUTING
2. receive packet from A->D
3. append one more ip/tcp headers from B->C to the packet
4. send it out
On machine C:
after i receive the packet, i will
5. remove the external ip/tcp headers
6. send it out to D
My question is at steps 3 and 5, after append/remove the packet and recalc the checksum, do i have to do something else relate to the socket/sock owner?
How to do steps 4 and 6 to send packet out?
Thank you very much for any help
Tim
|
|
|
03-25-2006, 03:15 PM
|
#2
|
Moderator
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696
|
Are you going to do the whole processing (appending headers and removing them) in the module or you plan to get it all out via sockets (on B and C)? Also, what kind of encapsulation do you think about? Remember, more complicated protocols mean more processing needed from your module. I think that IP over IP would be enough in most cases.
|
|
|
03-25-2006, 03:59 PM
|
#3
|
LQ Newbie
Registered: Mar 2006
Posts: 6
Original Poster
Rep:
|
Hi Mara, thanks for quick response,
Yes, i plan to do the whole thing in the module (kernel 2.4 netfilter hook). No user level program involved.
My task is provide a tunnel between B and C.
that will include:
-get the packet
-expand the packet by adding 2 more headers [IP header|TCP header][orginal ip packet]
-send the new one out
Assume I have enough information to fill up those extra headers (ips,ports,seq,ack...)
I just don't know what functions should I call in my module in order to send the packet out on the wire.
I know I have to do something like:
-create new skb (skb_copy_expand, skb_put...)
-fill up headers
-calc checksum
after this, what else should I do ? do i have to call skb_set_owner_w or something else related to skb->sk and skb->dev ?
and which function to send out the packet ?
THanks again. Please provide me some help.
|
|
|
03-27-2006, 03:14 PM
|
#4
|
Moderator
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696
|
You don't have to use any specific function to send it. You'll probably write a target. It doesn't really matter. What matters is the result (code) returned by your functions.
You just need to fill the packet (and the checksums). No need to run more things, with an exception, of course, when you need a specific thing done.
BTW In 2.6 there's ipt_REDIRECT. It may be interesting for you.
|
|
|
All times are GMT -5. The time now is 11:02 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|