LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-14-2012, 08:52 AM   #1
loolooyyyy
Member
 
Registered: Nov 2011
Posts: 36

Rep: Reputation: Disabled
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)

Last edited by loolooyyyy; 06-14-2012 at 09:59 PM.
 
Old 06-14-2012, 03:05 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,978

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
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.
 
Old 06-14-2012, 03:10 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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
 
Old 06-14-2012, 09:37 PM   #4
loolooyyyy
Member
 
Registered: Nov 2011
Posts: 36

Original Poster
Rep: Reputation: Disabled
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?

Last edited by loolooyyyy; 06-14-2012 at 09:59 PM.
 
Old 06-14-2012, 11:09 PM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^ 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.
 
Old 06-14-2012, 11:32 PM   #6
loolooyyyy
Member
 
Registered: Nov 2011
Posts: 36

Original Poster
Rep: Reputation: Disabled
it was so cool!

Last edited by loolooyyyy; 06-14-2012 at 11:34 PM.
 
Old 06-15-2012, 12:54 AM   #7
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Just use the same port to receive and send, on both machines. Networking is full duplex.
 
Old 06-15-2012, 04:01 AM   #8
loolooyyyy
Member
 
Registered: Nov 2011
Posts: 36

Original Poster
Rep: Reputation: Disabled
you mean
netcat -l -p 2020 Remote 2020?
sure!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting Two Linux Machines Mak007 Linux - Newbie 6 08-14-2011 08:48 PM
connecting two machines mushmaster Linux - Networking 8 10-15-2005 10:41 AM
Connecting 2 Linux machines ruh31 Linux - Networking 4 12-23-2004 02:04 AM
Win ME machines not connecting to server bobster666 Linux - Networking 7 03-04-2003 03:33 PM
connecting two machines vicente Linux - General 1 10-23-2001 07:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration