Link to home
Start Free TrialLog in
Avatar of fosiul01
fosiul01Flag for United Kingdom of Great Britain and Northern Ireland

asked on

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 ...




Avatar of farzanj
farzanj
Flag of Canada image

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
Avatar of fosiul01

ASKER

you mean.. write this line nc -l -p 1234 | dd of=/dev/sda

as

nc  192.168.0.12 1234 | dd of=/dev/sda

??
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 ..
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
I am assuming you are trying to use it like a client.
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

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
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...

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...