I want to make a kind of WiFi proxy. And therefore I want to know how can I reroute packets that are going through specific adapter to destination IP:port.
Asked
Active
Viewed 1,228 times
-2
-
It would help to have some information about the devices you are going to be using, this would help determine what approach can be taken to accomplish what you want. – Winter Faulk Nov 20 '12 at 19:46
-
What do you mean by "going through specific adapter"?! Do you mean packets received on a particular adapter? What were these packets originally sent to? Are you talking about bridging or routing? What do your IP addresses look like? Are you connecting devices on the same subnet or are you connecting distinct subnets? What you seem to be suggesting (to the extent I understand it) would be pointless since you'd never get any replies back. – David Schwartz Nov 20 '12 at 21:18
1 Answers
1
I assume you want to do that on a GNU/Linux system.
In order to re-route all the TCP traffic (since you're talking about packets) from a specific adapter to a specific IP address and port, you should:
Enable the IP forwarding capability of the Linux kernel. To do that, you must add the following configuration to /etc/sysctl.conf and reboot your system:
net.ipv4.ip_forward = 1
Next, create the iptables rule for the forwarding:
iptables -t nat -A PREROUTING -i $DEVICE -p TCP -d $IP --dport $PORT -j REDIRECT

dkaragasidis
- 745
- 4
- 11