LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   connecting two machines only using netcat? (http://www.linuxquestions.org/questions/linux-software-2/connecting-two-machines-only-using-netcat-4175411432/)

loolooyyyy 06-14-2012 08:52 AM

connecting two machines only using netcat?
 
i clarified my post:
i have Machine_A and Machine_B, and want to do this
[on A]
Code:

$ mkfifo F
$ pythonscrip connect localhost port 1212
$ netcat -l -p 1209 < F | netcat MACHINE_B_IP 1313 > F

[on B]
Code:

$ mkfifo F
$ pythonscrip connect localhost port 1212
$ netcat -l -p 1209 < F | netcat MACHINE_A_IP 1313 > F

but i get the error connection refused, running these:
`An Application Keep saying Hello to port 1209` On B : simply running
`netcat -l -p 1209 < F | netcat MACHINE_A_IP 1313 > F` on B : simply running
`telnet MACHINE_B 1313` on A : error: connection refused
i do this in test environment, live arch linux, on virtual machines, no iptables service or firewall running
A is: 192.168.1.10
B is: 192.168.1.20
virtual machines have an internal network, they can ping eachother, they can SSH to each other: which means they are connected,no network problem (i guess)

jefro 06-14-2012 03:05 PM

I am not sure I understand the issue. If you want to test nc then do it from command line. Then see if you can pipe it that way.

As to how to have a nc server you might look at my favorite two links.
http://www.ol-service.com/sikurezza/doc/netcat_eng.pdf
And.
http://www.sans.org/security-resourc...t_sheet_v1.pdf

And we may need to know the version of nc or netcat you have. Some do not act as expected. Some embedded and busybox versions are very limited.

schneidz 06-14-2012 03:10 PM

i am also not following your scenario but i do this sometimes (maybe it will help):
Code:

[schneidz@hyper stuff]$ cat /home/schneidz/stuff/netcat.com
#!/bin/bash
PL=$(find /root/user/music -name "*.mp3")
NUM=$(echo $PL |wc -w)
{
while true; do
r=$(($RANDOM%$NUM))
s=$(echo $PL |cut -d ' ' -f$r)
echo "HTTP/1.0 200 OK\nContent-Type: audio/x-mp3stream\n\n"
dd if=$s bs=1024
done
} | nc -l -s address -p 8020


loolooyyyy 06-14-2012 09:37 PM

i think i should apologize, i was too tired and sleepy to ask a question
i want to create a tunnel, which python scripts will use this tunnel to communicate
netcat: GNU netcat 0.7.1,
p1,p2 : py scripts , nc1,nc2 : netcat running on machine 1 and 2:
p1 <--localMachine1--> nc1 <==internet==> nc2 <--localmachine2--> p2
more simple:
p1 <--> nc1 <==> nc2 <--> p2

py script will receive and send data to netcat on port 2020 on localhost
netcat will receive and send data to other netcat on remote machine on port 3030

netcat has the option L, which is for tunneling, like this:
-L, --tunnel=ADDRESS:PORT forward local port to remote address
but when i do this on machine 1, what should i do on machine 2, so that the connection is accepted?

ps: i know i can do it using ssh flawlessly, but if you could help me do it using netcat, i'll be very grateful
ps2: thanks jefro, the cheat sheet was the only good one i've seen!
@schneidz: what does that script do?

schneidz 06-14-2012 11:09 PM

^ an example of playing a random mp3 on another computer such as a phone. i saw it as someones signature and thought it mite help in this instance.

loolooyyyy 06-14-2012 11:32 PM

it was so cool!

AwesomeMachine 06-15-2012 12:54 AM

Just use the same port to receive and send, on both machines. Networking is full duplex.

loolooyyyy 06-15-2012 04:01 AM

you mean
netcat -l -p 2020 Remote 2020?
sure!


All times are GMT -5. The time now is 10:25 AM.