nc both fails and succeeds

7,612

Shortly after posting, I found the problem:

[jadavis6@ditirlns01 ~]$ host ditirldv02.ncat.edu
ditirldv02.ncat.edu has address 152.8.143.20
ditirldv02.ncat.edu has address 152.8.143.5
[jadavis6@ditirlns01 ~]$

So it appears that nc will cycle through all A records for a given host and test each one individually. The first failure was for the incorrect IP address, the success was for the correct one.

Share:
7,612

Related videos on Youtube

Bratchley
Author by

Bratchley

Updated on September 18, 2022

Comments

  • Bratchley
    Bratchley over 1 year

    Platform: RHEL 5.10

    netcat Version: 1.84-10.fc6

    I was trying to figure out if my inability to ssh was TCP-level and usually I use nc for this. This time, however, I got something unexpected.

    [jadavis6@ditirlns01 ~]$ nc -vz dixxxldv02.xxx.xxx 22 -w 15
    nc: connect to dixxxldv02.xxx.xxx port 22 (tcp) timed out: Operation now in progress
    Connection to dixxxldv02.ncat.edu 22 port [tcp/ssh] succeeded!
    

    Normally if it can't connect within the specified timeout it just prints the first line. Thinking it was just some weird race condition (like the TCP connection kept completing just as I was approaching timeout) I lengthened the timeout period to 30 seconds but got the same exact results.

    Telnet also fails so I think there is an IDS/Network Firewall blocking the traffic. I was just curious if anyone has seen this before or what it mean.

  • slm
    slm over 10 years
    That's usually how it goes 8-)