How can I redirect/forward all the UDP/TCP traffic on one interface to another interface in OpenWrt
Posted
by
Sina Sou
on Server Fault
See other posts from Server Fault
or by Sina Sou
Published on 2013-10-26T14:55:24Z
Indexed on
2013/10/26
15:56 UTC
Read the original article
Hit count: 256
I am new to networking and I have a measurement device (D) that periodically sends all its readings over few UDP multicast sockets (with different multicast IP addresses and different port numbers).
That device even listens to a TCP socket simultaneously to modify its configuration on port 7234.
Since the device has just a Ethernet interface for communication and I want to make it work wireless, I decided to use a very small wireless open-wrt based router that attaches to the device (D) and redirect/forward all the network traffic(Both UDP/TCP) to the router wireless interface.
In order to simplify the problem assume that the Device (D) establishes following sockets (at the same time)
UM_SOCK1: UDP mcast socket on 239.1.2.3 port# 50620 UM_SOCK2: UDP mcast socket on 239.1.2.4 port# 50640 TC_SOCK3: TCP DHCP/STATIC ip address 192.168.1.200 port 7234
And (D) is connected to Open-Wrt router (R) via interface en01 (Ethernet) the router has it own wireless interface on (wlan0)
I want all the traffic from interface pass through wlan01 and vice versa (bi-directional) en01 <----> wlan01
What would be the minimum iptables or ... commands that I need to make this possible?
Even I am wondering if traffic directing can be made easier like if the direction is not going to be based on IP addresses(not desired if the device is connected via DHCP)
I would rather redirection to be Interface(en0) based or on MAC address (The best solution since my device has unique MAC address)?
Thanks
© Server Fault or respective owner