查找由Linux中的可执行程序设置的套接字选项 [英] find socket options set by an executable program in Linux

查看:65
本文介绍了查找由Linux中的可执行程序设置的套接字选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找出在打开与服务器的TCP连接时正在执行的客户端程序设置的套接字选项.客户端正在Linux上运行.在/proc/tcp 下可用吗?

I need to find out the socket options that an executing client program has set while opening TCP connections to a server. The client is running on Linux. Is it available under /proc/tcp?

推荐答案

我也需要这样做.

lsof 并没有太大帮助,因为tcp选项没有作为标准显示在/proc/中.

lsof doesn't help much as the tcp options aren't exposed in /proc/ as standard.

我使用了这个内核模块 https://github.com/veithen/knetstat 我也对其进行了修改以使其与较早的内核版本一起使用: https://github.com/abligh/knetstat

I used this kernel module https://github.com/veithen/knetstat which I modified to work with older kernel versions as well here: https://github.com/abligh/knetstat

这可让您执行以下操作:

This lets you do:

# cat /proc/net/tcpstat | head
Recv-Q Send-Q Local Address           Foreign Address         Stat Diag Options
     0      0 0.0.0.0:16013           0.0.0.0:*               LSTN      SO_REUSEADDR=0,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 127.0.0.1:25            0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=1,TCP_NODELAY=0
     0      0 0.0.0.0:111             0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 0.0.0.0:4643            0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 127.0.0.1:753           0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 127.0.0.1:113           0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 127.0.0.1:754           0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 127.0.0.1:1234          0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_KEEPALIVE=0,TCP_NODELAY=0
     0      0 0.0.0.0:53618           0.0.0.0:*               LSTN      SO_REUSEADDR=0,SO_KEEPALIVE=0,TCP_NODELAY=0

这篇关于查找由Linux中的可执行程序设置的套接字选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆