I have a Linux box with two lan interfaces, where one is connected to an embedded system device via 192.168.232.0/24 and the other one to a PC via 192.168.236.0/24.
I now want to access the embedded system device from the PC. So the linux box should be simply a gateway or bridge. I cannot change the network settings on the embedded system device.
The interfaces are configured like this:
PC Link encap:Ethernet HWaddr 00:30:D6:25:3E:0C
inet addr:192.168.236.1 Bcast:192.168.236.255 Mask:255.255.255.0
inet6 addr: fe80::230:d6ff:fe25:3e0c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
...
XTH Link encap:Ethernet HWaddr F8:02:78:20:35:28
inet addr:192.168.232.250 Bcast:192.168.232.255 Mask:255.255.255.0
inet6 addr: fe80::fa02:78ff:fe20:3528/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
...
192.168.232.0/24 dev XTH proto kernel scope link src 192.168.232.250
192.168.236.0/24 dev PC proto kernel scope link src 192.168.236.1
The network layout:
Emb.System Linux
--------------- ------------------------- PC
|192.168.232.1| <-> | (XTH) 192.168.232.250 | -----------------
--------------- | (PC) 192.168.236.1 | <-> |192.168.236.100|
------------------------- -----------------
I tried to forward the required UDP ports 5554 and 5555. The request goes from the PC to the correct interface, but there is no answer. I guess this happens, because the embedded system device mask is 255.255.255.0 and it does not know to route back to 192.168.236.100.
My changes to iptables:
iptables -t nat -A PREROUTING -p udp -i PC --dport 5554 -j DNAT --to-destination 192.168.232.1
iptables -t nat -A PREROUTING -p udp -i PC --dport 5555 -j DNAT --to-destination 192.168.232.1
iptables -A FORWARD -p udp -d 192.168.232.1 --dport 5554 -j ACCEPT
iptables -A FORWARD -p udp -d 192.168.232.1 --dport 5555 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.232.1 -o PC -j MASQUERADE
A tcpdump on the XTH interface shows me, that the incoming pakets are seen on the correct interface, but no answer:
13:40:54.074335 IP 192.168.236.100.51792 > 192.168.232.1.5554: UDP, length 12
13:40:57.074852 IP 192.168.236.100.51796 > 192.168.232.1.5554: UDP, length 12
13:41:00.076614 IP 192.168.236.100.51800 > 192.168.232.1.5554: UDP, length 12
13:41:03.077755 IP 192.168.236.100.51804 > 192.168.232.1.5554: UDP, length 12
13:41:06.078906 IP 192.168.236.100.51808 > 192.168.232.1.5554: UDP, length 12
Is it possible to solve this problem without changing the subnet mask configuration in the embedded system device? I would be very grateful for any ideas that could help me solve the problem.
Faul Pelz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.