Skip to content

Instantly share code, notes, and snippets.

@kitsuyui
Created April 15, 2016 23:03
Show Gist options
  • Save kitsuyui/7f0d0c59f4d2db5738cb53d52d615043 to your computer and use it in GitHub Desktop.
Save kitsuyui/7f0d0c59f4d2db5738cb53d52d615043 to your computer and use it in GitHub Desktop.
nc -v -z すると 2 つ結果を返すのはなぜか? ref: http://qiita.com/kitsuyui/items/cbac88800dfe5cfb8dcb
$ nc -v -z localhost 8000
nc: connectx to localhost port 8000 (tcp) failed: Connection refused
nc: connectx to localhost port 8000 (tcp) failed: Connection refused
$ nc -v -z localhost 8000 ; echo $?
nc: connectx to localhost port 8000 (tcp) failed: Connection refused
found 0 associations
found 1 connections:
1: flags=XX<CONNECTED,PREFERRED>
outif XXX
src 127.0.0.1 port XXXXX
dst 127.0.0.1 port 8000
rank info not available
TCP aux info available
Connection to localhost port 8000 [tcp/irdmi] succeeded!
0
$ nc -v -z 127.0.0.1 8000
nc: connectx to 127.0.0.1 port 8000 (tcp) failed: Connection refused
$ nc -v -z ::1 8000
nc: connectx to ::1 port 8000 (tcp) failed: Connection refused
$ nc -v -z -4 localhost 8000
nc: connectx to localhost port 8000 (tcp) failed: Connection refused
$ nc -v -z -6 localhost 8000
nc: connectx to localhost port 8000 (tcp) failed: Connection refused
$ /usr/local/bin/nc -v -z localhost 8000
localhost [127.0.0.1] 8000 (irdmi): Connection refused
$ /usr/bin/nc -v -z -G 1 localhost 8000
nc: connectx to localhost port 8000 (tcp) failed: Connection refused
nc: connectx to localhost port 8000 (tcp) failed: Connection refused
nc: connectx to localhost port 8000 (tcp) failed: Operation timed out
nc: connectx to localhost port 8000 (tcp) failed: Operation timed out
nc: connectx to localhost port 8000 (tcp) failed: Operation timed out
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.2 localhost
127.0.0.3 localhost
127.0.0.4 localhost
255.255.255.255 broadcasthost
::1 localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment