Linux View open network ports

Use netstat

netstat -nape can list all ports connection has been established and listening states

For embedded busybox, netstat command may not list the name of the program to open the port, there are two methods:

  1. Configuring busybox

Recompile busybox, supported the -p option lists the name of the program

    2. The / proc file system to find

View all tcp ports open system

a)cat /proc/net/tcp

local_address column is ip: port, here are the hexadecimal

inode: open socket corresponding inode

 

b) Find inodeno corresponding process ID

for dir in `find /proc/ -name "fd"`; do ls -l $dir | grep 'socket\:\[13849\]' && echo $dir;done

 

c) process number to get the name of the process according to

head -n 1 /proc/2135/status

3841 As can be seen, for the band 10 to 14,401, the program opens the port named sshd

Also by this method can be viewed udp open ports, netstat program through the above process is actually open port information displayed

 

 

For the client side, the method is not applicable, then we should use a log function or TCPdump iptables tool, iptables invalid output prints out all dropped packets, which will see the port number for

Published 85 original articles · won praise 26 · views 120 000 +

Guess you like

Origin blog.csdn.net/whuzm08/article/details/82872900