This is so cool and unexpected, but then nothing out of spec, that I had to reblog it. Namely, if you run the following snippet of the Bourne shell code: while truedo telnet 127.0.0.1 50000done You'll constantly receive message 'Connection refused', but at one point the connection will be established and whatever you type, will be echoed back: Trying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refusedTrying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refusedTrying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refusedTrying 127.0.0.1...telnet: connect to address 127.0.0.1: Connection refusedTrying 127.0.0.1...Connected to 127.0.0.1.Escape character is '^]'.test1test1test2test2 Note that you didn't start any server and there is no process listening on port 50000 on localhost, but yet, it connected! Looking at the output of netstat command we see that there is really established connection: $ netstat -tn | grep 50000tcp 0 0 127.0.0.1:50000 127.0.0.1:50000 ESTABLISHED and, if we monitor traffic using tcpdump we observe a three way handshake: 21:31:02.327307 IP 127.0.0.1.50000 > 127.0.0.1.50000: Flags [S], seq 2707282816, win 43690, options [mss 65495,sackOK,TS val 41197287 ecr 0,nop,wscale 7], length 021:31:02.327318 IP 127.0.0.1.50000 > 127.0.0.1.50000: Flags [S.], seq 2707282816, ack 2707282817, win 43690, options [mss 65495,sackOK,TS val 41197287 ecr 41197287,nop,wscale 7], length 021:31:02.327324 IP 127.0.0.1.50000 > 127.0.0.1.50000: Flags [.], ack 1, win 342, options [nop,nop,TS val 41197287 ecr 41197287], length 0 What happened? In short, client connected to itself. :) A bit longer explanation follows... Let's start with a fact that when a client (in this case it is a telnet application) creates socket and tries to connect to server, kernel assigns it a random source port number. This is because each TCP connection is uniquely identified with 4-tuple: (source IP, source port, destination IP, destination port) Of tho...
First seen: 2025-08-11 04:46
Last seen: 2025-08-11 10:49