LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   lsof and nfs connections (https://www.linuxquestions.org/questions/linux-networking-3/lsof-and-nfs-connections-907748/)

gettons1980 10-12-2011 06:28 AM

lsof and nfs connections
 
Hi all,


while I was playing with lsof and netstat I noticed something strange, or at least something I couldn't figure it out.

I have an nfs v3 share mounted and I can see the connection established with the server by running netstat.
Quote:

[root@MYHOST ~]# netstat -natpl | grep ':2049'
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 152 10.241.95.183:667 10.241.95.101:2049 ESTABLISHED -
tcp 0 0 10.241.95.183:1005 10.241.95.101:2049 ESTABLISHED -
tcp 0 0 10.200.31.195:1011 10.241.102.135:2049 ESTABLISHED -
tcp 0 0 10.241.95.183:985 10.241.95.100:2049 ESTABLISHED -
tcp 0 0 10.241.95.183:909 10.241.95.100:2049 ESTABLISHED -
tcp 0 0 10.241.95.183:937 10.241.95.100:2049 ESTABLISHED -
tcp 0 0 10.241.95.183:817 10.241.95.100:2049 ESTABLISHED -

I was expecting to see this connection also by running lsof, but this is not the case.

[QUOTE]
-
[root@MYHOST ~]# lsof -nn -P -i | grep '2049'
[root@MYHOST ~]# lsof -nn -P | grep '2049'



Could you clarify this point to me please ?

foodown 10-12-2011 06:50 AM

You need to add the -N flag.

gettons1980 10-12-2011 07:27 AM

Hi there,


actually lsof -N displays just nfs files related, but by running lsof it should pick all type of files.
I have also tried -N option anyway but nothing changed ( see below )
What I am looking for is not the open file ( in this case the test file I am editing with vi ) but the actual tcp connection established with the nfs server.

Quote:

[root@MYHOST ~]# lsof -nn -P| grep '10.241.121.82'
sshd 3936 root 3u IPv6 42305517 TCP 10.200.31.87:22->10.241.121.82:37833 (ESTABLISHED)
sshd 3941 lcp25o 3u IPv6 42305517 TCP 10.200.31.87:22->10.241.121.82:37833 (ESTABLISHED)
vim 22169 root 3u REG 0,28 12288 18087950 /media/.test.swp (10.241.121.82:/media)
sshd 22189 root 3u IPv6 42340155 TCP 10.200.31.87:22->10.241.121.82:39429 (ESTABLISHED)
sshd 22191 lcp25o 3u IPv6 42340155 TCP 10.200.31.87:22->10.241.121.82:39429 (ESTABLISHED)

[root@MYHOST ~]# lsof -nn -P -N | grep '10.241.121.82'
vim 22169 root 3u REG 0,28 12288 18087950 /media/.test.swp (10.241.121.82:/media)


All times are GMT -5. The time now is 04:23 PM.