• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2907
  • Last Modified:

nc command does not connect to remote host (debain lenny)

Hi
this problem making me mad ..

Server 2 ( Remote host)
nc -l -p 1234 | dd of=/dev/sda

Server 1( Source)(
dd if=/dev/sda | nc 192.168.0.12 1234



in Server 2 :

it shows that port is listing ..


Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:1234            0.0.0.0:*               LISTEN


but there is not any data copy from serveer 1 to server 2 !!!


after typing the command in server 1
dd if=/dev/sda | nc 192.168.0.12 1234

its seems that its working!!
example :
root      2307  0.0  0.1   2876   616 tty1     S+   16:17   0:00 dd if /dev/sda


but reality .. Server 1 does not even connect to server2, as netstat -ant  | grep 1234 in SErver 2 does not shows any established connection ...

example :

root@Microknoppix:~# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:1234            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN



any idea whats happening ??


Please help ...




0
fosiul01
Asked:
fosiul01
  • 5
  • 3
  • 2
1 Solution
 
farzanjCommented:
Don't use option l.  IT is to make it act like a server.
Netcat works as both client and server.  If you want to make it run like a client, do not use option l which is to make it listen --act like server.
Just say.  

nc <IP_ADDRESS> 1234
0
 
fosiul01Author Commented:
you mean.. write this line nc -l -p 1234 | dd of=/dev/sda

as

nc  192.168.0.12 1234 | dd of=/dev/sda

??
0
 
woolmilkporcCommented:
Using "-p" with "-l" is wrong.

Use

nc -l 1234

wmp
0
The IT Degree for Career Advancement

Earn your B.S. in Network Operations and Security and become a network and IT security expert. This WGU degree program curriculum was designed with tech-savvy, self-motivated students in mind – allowing you to use your technical expertise, to address real-world business problems.

 
fosiul01Author Commented:
i want to make server2 to listen on port 1234

so that Server1 can conenct to that port and transfer data

what you say ??




bellow 2 command

Server 2 ( Remote host)
nc -l -p 1234 | dd of=/dev/sda

Server 1( Source)(
dd if=/dev/sda | nc 192.168.0.12 1234

works fine on different server but with this one it does not ..
0
 
farzanjCommented:
nc  192.168.0.12 1234 | dd of=/dev/sda

This should read from 192.168.0.12 and write on your device /dev/sda
0
 
farzanjCommented:
I am assuming you are trying to use it like a client.
0
 
fosiul01Author Commented:
let me tell you

http://www.howtoforge.com/useful-uses-of-netcat


Server 1 is Source

server 2 is desitiation


Server 2 ( Remote host)
nc -l -p 1234 | dd of=/dev/sda

Server 1( Source)(
dd if=/dev/sda | nc 192.168.0.12 1234


so i am cloning data from Server1 to Server 2


those command works fine with another server i already cloned
but with this debain lenny server.. its not working



Here..

Server 2   is activing as Server

Server 2 ( Remote host)
nc -l -p 1234 | dd of=/dev/sda


and Server 1 is connecting this server 2 via port 1234, then sending all data to server2 for cloning..

I can telnet from server1 to server 1

telnet 192.168.0.12  1234

its works

but when i am trying to use NC

its not connect

0
 
woolmilkporcCommented:
Sorry, fosiul,

with Debian you're correct using "-p".

I accidentally thought of BSD Unix, where it's wrong.

Are you sure that it doesn't connect, or does it just not come to an end?

You could try -w1 at the sending side to set a timeout of 1 second.

And please be patient - maybe you'll just have to wait long enough?

wmp
0
 
fosiul01Author Commented:
Hi

i h ave used this command into different server its works fine
but only with this one .. its not ..

when Server1 conencts to server2 via port 1234

in netstat -ant its always say, its connected

whch meants the cloning started.. but here
its always saying

root@Microknoppix:~# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:1234            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN


which means server 1 did nto connect to the server2...

0
 
fosiul01Author Commented:
I found this in server and client


in the server


 dd if=/dev/sda | nc -v  192.168.0.145 1234
129+0 records in
128+0 records out
65536 bytes (66 kB) copied, 2.30915 seconds, 28.4 kB/s

Warning: forward host lookup failed for 37l4247e19-11.xxxxx.lan: Unknown host
37l4247e19-11.xxxxx.lan [192.168.0.145] 1234 (?) open


In client :

nc -l -v -p 1234 | dd of=/dev/sda
listening on [any] 1234 ...
192.168.0.28: inverse host lookup failed: Unknown host
connect to [192.0.0.145] from (UNKNOWN) [192.168.0.28] 47133
106+27 records in
128+0 records out
65536 bytes (66 kB) copied, 10.683 s, 6.1 kB/s


do you think its the problem ??

i think so...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now