I have an ADB daemon running on localhost:5037 on my machine. I have a virtual machine running on my machine. Let's call my machine host and the virtual one guest.
The guest VM uses host's interface:
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
to connect to the internet. I need to access the ADB server at my host from inside guest. If I just call 192.168.122.1
from inside guest it does not work because adb on host is bound to localhost:5037, not 192.168.122.1:5037, therefore I need a way to map
192.168.122.1:5037 <-> localhost:5037
on the host machine in a bidirectional way.
If I just add a bridge between everything then it'll mess how my VM works because it depends on this interface to connect to the internet.
How can I create a TCP bridge between these 2 IPs? I found http://tcpreplay.synfin.net/wiki/tcpbridge but it's unclear how it works. Maybe iptables can solve this?
UPDATE:
as recommended in the answer, I used socat and now it works:
#on host machine:
socat tcp-listen:5037,bind=192.168.122.1,reuseaddr,fork tcp:localhost:5037
#on virtual machine:
socat tcp-listen:5037,bind=localhost,reuseaddr,fork tcp:192.168.122.1:5037