OpenWrt Forum Archive

Topic: Chained routers

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

All,
first time here, not sure this is the right place but I hope you all indulge me.

I am in the process of developing a device which is controlled by a PC via TCP. I envision the device to contain a router.
If I connect my PC and the device to the same router on the AN side all is well. However, to network several devices to the same PC I will need the following topology:


PC -----  Main Router      -----------      Device1 Router ---- Device 1
                                      |
                                        -----------      Device2 Router -- Device 2

The devices are connected to the LAN ports on the Device routers, the device router WAN ports are connected to a LAN port on the Main Router as well as the PC. the main router's LAN is 192.168.1.0, the device routers use 10.0.69.0
Each device router has a static IP for the device and incoming traffic is routed to the device. It's WAN IP is obtained via DHCP from the main router.

I connect to the devices on ports 55001 and 55002 and this all works fine (port forwarding works after I figured out thanks to a post that I have to Masquerade the Lan -> WAN zones)

Here are the problems:

1) The PC sends a broadcast (255.255.255.255) on port 55100 using UDP and all devices are supposed to answer. I use this to discover what's out there (custom message, none of the established discovery protocols)
Problem: this packet never gets to my devices and the cannot answer.  I tried to forward port 55100 also, doesn't work.

2) Each device is supposed to connect to the PC on a unique port (55003 - 55099) to be able to send messages to the PC. This does not work at all: when my code on device1 or device2 tries to connect a socket back to the device, I get an "unreachable host" exception.
I presume there is something with IP tables but I cannot figure it out.

Obviously, both, the main and device routers run OpenWrt.

If anybody has any ideas what's wrong and which - if any - custom firewall settings I might need, I would appreciate any help I can get.

Thanks

My two cents:

1) Broadcast packets do not cross routers. You should configure the router as a bridge instead (and have just one big network), or listen to the broadcast messages on the router, or do some kind of special forwarding that I do not about. You could be tempted to use "relayd" (as it was designed specifically to relay broadcast packets), but take into consideration other broadcast messages (such as DHCP, for example).

2) Are the device routers to masquerade traffic or just route it? Is the PC configured to accept traffic from a 10.x.y.z network?

Thanks for the reply.

1) I am not sure I can use bridged since the main router may be a customer router and it is my understanding that my device routers in this case would need to know the main router's IP?
"Relayed" sounds good since my PC is except for my own broadcast oblivious to anything else. Any idea how to configure this?

2) The outside PC should not "know" about the 10.x.y.z network, just about the main router

You are creating a dogs-breakfast of networking. Trying to do NAT traversal with your two routers is creating an unnecessarily complex configuration. I would suggest:
1) turning off NAT on your routers, and entering static routes (or run a routing protocol like RIP/OSPF) so that Device 1 can get to Device 2 (in your drawing)
2) moving to IPv6, which doesn't have NAT, and will be compatible with networks into the next century.

The discussion might have continued from here.