2

I’m using a Linux (Debian based) system on which IP forwarding is enabled (/proc/sys/net/ipv4/ip_forward is set to 1). I can read the incoming packets using a raw sockets program, but I want to modify their content before they are forwarded. This link mentions that I can use an iptables REDIRECT rule to send the incoming packets to a port my program is listening on, but I didn’t find any information on how exactly this should be done. Mainly, I want to know:

  1. How I should forward the packets after modifying them. Do I have to send them manually from the program to their destination address after they are received and modified?

  2. What I should do in case the program isn't listening on a particular port (e.g. a program concerned with only the IP headers of the packets).

In case it matters receiving and forwarding are done on the same interface (wlan0). I have to forward packets to, and receive packets from devices on the same WLAN.

2
  • What kind of modification are you planning? Some can be done in iptables itself.
    – Paul
    Nov 26, 2014 at 5:49
  • @Paul Basically I have to modify some ICMP packets but it's better if the program can do it (in case I have to do something very particular in the future). Nov 26, 2014 at 6:08

0

You must log in to answer this question.

Browse other questions tagged .