Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-05-09
10
Medium Priority
?
2,242 Views
Last Modified: 2012-05-11
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
Comment
Question by:fosiul01
  • 5
  • 3
  • 2
10 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 35721324
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
 
LVL 29

Author Comment

by:fosiul01
ID: 35721351
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
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1500 total points
ID: 35721369
Using "-p" with "-l" is wrong.

Use

nc -l 1234

wmp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 29

Author Comment

by:fosiul01
ID: 35721376
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
 
LVL 31

Expert Comment

by:farzanj
ID: 35721387
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
 
LVL 31

Expert Comment

by:farzanj
ID: 35721396
I am assuming you are trying to use it like a client.
0
 
LVL 29

Author Comment

by:fosiul01
ID: 35721431
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
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35721596
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
 
LVL 29

Author Comment

by:fosiul01
ID: 35721652
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
 
LVL 29

Author Comment

by:fosiul01
ID: 35721823
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question