On 6/19/05, John Que <qwejohn@xxxxxxxxxxx> wrote: > I want to be able to recieve UDP packets which are destined > to machine x and to send them (also by UDP) to different > addresses. > I want to do it in kernel mode so that it will be more efficent. > Let's say at this stage that I know a different IP address > to which the packet will be sent. (Later it will be a table). > I wrote a module which receices packets using nf_register_hook() > of netfilter.It works OK;I am using the NF_IP_PRE_ROUTING hook ; I > tested sending UDP packets on a certain > port and I verified they get to the hook method. > > What should I do in order to change the destination IP address > so it will be to a different address? > Should I only change the IP address of the destination in the UDP > header?? > I started digging into the netfilter layer in the kernel but it is > quite complex. > > Which hook should I use ? is it NF_IP_PRE_ROUTING ? > or NF_IP_FORWARD ? > Any Idea? Hi John, I think ur hook should be in NF_IP_FORWARD because u want to change the destination address from x to y. If u know that this x != UR_OWN_IP then NF_IP_FORWARD makes sense. I think u'll also need to change the checksums in the IP and UDP header, otherwise the receiving machine would not accept the packets. HTH, Rajat. http://rajatswarup.blogspot.com -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/