I have 2 systems ubuntu A and B.
IP Address: 192.168.0.5 B IP Address: 192.168.0.3
System A runs an Android emulator. I have a TCP Client application that needs to communicate with system B.
Since Android applications can “see” localhost (like 10.0.2.2), the client application sends a message at 10.0.2.2 to the Pb port.
Now I assume that System A should see that any message that it receives on its localhost (for example, 127.0.0.1, which is 10.0.2.2 for the emulator) in the Pb port should be redirected to System B 192.168.0.3 on the port Pb. Therefore, I installed the following in System A:
echo "1" </ Transactions / Systems / Net / ipv4 / ip_forward
sudo iptables -t nat -A PREROUTING -p tcp -s 127.0.0.1 -d 127.0.0.1 -dport Pb -j DNAT -to-destination 192.168.0.3:Pb
System B starts the TCP server on IP 192.168.0.3 and the Pb port
Using these rules on systems A and B, I run the android emulator for system A, and then the TCP Client application on Andoid.
The Wireshark tool shows packets reaching 127.0.0.1, but my server in System B does not receive any packets at all :(
What's wrong?
-------------------- --------------------------
System A System B
192.168.0.5 wlan0 192.168.0.3 wlan0
127.0.0.1 lo 127.0.0.1 lo
<---------------->
Android EMULATOR TCP Server
TCP CLient App at 192.168.0.3, port Pb
at 10.0.2.2
---------------------- ----------------------------
Please, help.
source
share