Skip to content

Instantly share code, notes, and snippets.

@adrianlzt
Created October 7, 2013 09:07
Show Gist options
  • Save adrianlzt/6864843 to your computer and use it in GitHub Desktop.
Save adrianlzt/6864843 to your computer and use it in GitHub Desktop.
Netcat testing 3306 tcp connexion
[root@centos mysql]# nc -vz localhost 3306
nc: connect to localhost port 3306 (tcp) failed: Connection refused
Connection to localhost 3306 port [tcp/mysql] succeeded!
The reason is the first connection is against ::1 (IPv6), and the second to 127.0.0.1.
This could be seen with: tcpdump -i lo -n
[root@centos mysql]# grep localhost /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
iptraf doesn't show this correctly, hidding the ipv6 connection under the ipv4 connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment