Skip to contentSkip to conversation

Urgent SNAT help required

DISCUSSION cranium2003 2 participants 2 messages May 9, 2005 netfilter

lore
Share & tools
lore
#0 lore raw

hello,
I want to execute my code at
NF_IP_POST_ROUTING. For that First i want to know which functions are executing at NF_IP_POST_ROUTING Hook. Then i have enabled SNAT and I have wrriten code at NF_IP_POST_ROUTING but i want to get outgoing packets' IP address as new one SNAT'ed IP address not the one that is before SNAT? How can i do that?
I observe that my code and SNAT are executing
at same HOOK NF_IP_POST_ROUTING. But my code is executed first and then SANT is doen but how to reverse that?
regards,
cranium

Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html

#1 lore raw
Quoted 8 lines · On 5/9/05, cranium2003 <[email protected]> wrote:

hello,
I want to execute my code at
NF_IP_POST_ROUTING. For that First i want to know which functions are executing at NF_IP_POST_ROUTING Hook. Then i have enabled SNAT and I have wrriten code at NF_IP_POST_ROUTING but i want to get outgoing packets' IP address as new one SNAT'ed IP address not the one that is before SNAT? How can i do that?

Execute your code after SNAT has finished.

Quoted 4 lines

I observe that my code and SNAT are executing
at same HOOK NF_IP_POST_ROUTING. But my code is executed first and then SANT is doen but how to reverse that?

Use the following while declaring an nf_hook_ops struct:
struct nf_hook_ops post_route = {
{NULL, NULL},
post_route_handler,
THIS_MODULE,
PF_INET,
NF_IP_POST_ROUTING,
NF_IP_PRI_NAT_SRC +1, // <--- This is important. It is the priority.
};

Note that the last field gives the priority for this handler. The higher it is, the earlier it is executed.

HTH,
Vinay

Quoted 8 lines

regards,
cranium

Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html

Signature · 3 lines
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan