Active connections conundrum involving lsof / netstat output
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Ubuntu 16.04.7 LTS, Kali, MX Linux with i3WM
Posts: 299
Rep:
Active connections conundrum involving lsof / netstat output
Hi, just something which I find a bit confusing and I wonder if anyone could kindly clarify things.
Currently I am using the web ( logged into LQ) and listening to music using xmms which has opened a M3U playlist file and is streaming the music from a remote server. Now when I run netstat -ta to show my active connections only the connection to the music server appears and my connection to LQ ( or any other web site) is not shown. The same happens when I run the lsof -i:80 command.
Code:
[uncle@localhost Desktop]# netstat -ta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:netbios-ssn *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ipp *:* LISTEN
tcp 0 0 *:microsoft-ds *:* LISTEN
tcp 90192 0 192.168.0.11:2213 apache2-twiddle.yoohoo:http ESTABLISHED
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:ipp *:* LISTEN
Code:
[uncle@localhost Desktop]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
xmms 14404 uncle 14u IPv4 1640859 TCP 192.168.0.11:4977->apache2-twiddle.yoohoo.dreamhost.com:http (ESTABLISHED)
apache2-twiddle.yoohoo.dreamhost.com is the music server.
I assumed that netstat -ta would show all my active TCP connections so why is the connection to the LQ web server not shown when using either the netstat or lsof commands ?
Thanks again !
Uncle
Ps: I have run both commands as root and get the same output.
Last edited by uncle-c; 12-08-2007 at 07:27 PM.
Reason: additional material added.
I believe this is because the connection to LQ is made just to download the web page and then closed. Once the page is displayed, the connection has already been closed, as opposed to streaming music, which leaves the connection open while there are still things to download, until the music is stopped.
Distribution: Ubuntu 16.04.7 LTS, Kali, MX Linux with i3WM
Posts: 299
Original Poster
Rep:
Thanks for the reply Agrouf, but surely if I am logged in and typing as I am now, the connection to LQ will remain open and thus should show up in netstat / lsof ?
No, I don't think so.
When you are typing, you are typing on firefox (or whatever browser). The connection to LQ is done only when you hit 'send reply'.
To test it, just type something and close your browser. Open again and see that your message is lost. LQ is not aware of what you typed until you send it with 'send reply'
Thanks for the reply Agrouf, but surely if I am logged in and typing as I am now, the connection to LQ will remain open and thus should show up in netstat / lsof ?
No. You are typing into a local application (a form in a web browser). You do not make a connection back to the webserver until you "submit" the form.
Distribution: Ubuntu 16.04.7 LTS, Kali, MX Linux with i3WM
Posts: 299
Original Poster
Rep:
Thanks very much Agrouf / David. Apologies in advance for asking trivial questions but the answers always help one grasp a better understanding of the underlying methods and concepts.
To further demonstrate the point already made by the others, you could observe the active connection to LQ (if you can catch it) by making your browser nice and small and then putting a terminal next to it running the command: $ watch -n 1 netstat -ta
Reload the page and see the active connection appear and disappear...
Distribution: Ubuntu 16.04.7 LTS, Kali, MX Linux with i3WM
Posts: 299
Original Poster
Rep:
Thanks anomie.I tried the above. I was on a specific website and did no input of any kind but was given a constant "Established" output in my netstat command. Could that be the web server sending me a constant stream of data / info of some description ? Sometimes when I quit a page totally I am left with netstat outputs such as Listen /wait ( from the site I am connected to). Is this the client waiting for some repsonse from the server so it can terminate or continue the connection ?
Sometimes when I quit a page totally I am left with netstat outputs such as Listen /wait ( from the site I am connected to). Is this the client waiting for some repsonse from the server so it can terminate or continue the connection ?
You may be interested in looking at the netstat(8) manpages, under the 'State' section. This lists brief but (mostly) helpful descriptions of some of the various connection states.
---
As for why you see different behaviors with different websites, hard to say. For pages that reload themselves frequently and/or load advert material (such as yahoo), I'd imagine you may see an established connection even if you're not posting requests yourself.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.