I have been able to make a phone calls using the SIP client Pjsua from one Linux computer to another one. In case you have not heard of this user agent, explaining it's functionality is quite easy. It uses IP and port number of each linux to create a unique ID and then calling to this specific ID is possible.
Now I have not studied port forwarding thoroughly but I suppose what it does is to forward whatever data that comes in, to another "port" or "IP and port".
So I thought to myself, if my calling application is using ports and IPs to send and receive voice, I should be able to forward those specific ports to a second or third port (or IP and port) and listen to the conversation on a third computer.
So here is what I did.
Supposing that machine Linux A has the following identification info:
IP:192.168.1.11` `UDP port# : 1111
The second machine Linux B has the following identification:
IP:192.168.1.22` `UDP port# : 2222
If I do the following using
iptables I should be able to hear that side of the conversation which is being received on Linux B on a 3rd system, Linux C .
The third machine, Linux C has the following identification info:
IP:192.168.1.33` `UDP port# : 3333
To achieve this, I tried running this command on Linux B:
$ iptables -t nat -A PREROUTING -p udp --dport 2222 -j DNAT --to-destination 192.168.1.33:3333 //forward port 2222 to Linux C on port 3333
And ran this command on Linux C:
$ aplay | nc -l -u 3333 //listen on the specified UDP port
However I don't hear anything on Linux C.
Can anyone tell me why this is not working? Other strategies to do something like this are also welcome.