linux/windows 验证端口是否打开

Posted on Posted in command, windows
  1. lsof
$ sudo lsof -i -P -n
$ sudo lsof -i -P -n | grep LISTEN
$ doas lsof -i -P -n | grep LISTEN  ### OpenBSD
  1. netstat
  • linux
$ netstat -tulpn | grep LISTEN
  • FreeBSD/MacOS X
$ netstat -anp tcp | grep LISTEN
$ netstat -anp udp | grep LISTEN
  • OpenBSD
$ netstat -na -f inet | grep LISTEN
$ netstat -nat | grep LISTEN
  1. nmap
$ sudo nmap -sT -O localhost
$ sudo nmap -sU -O 192.168.2.13 ### 列出打开的 UDP 端口
$ sudo nmap -sT -O 192.168.2.13 ### 列出打开的 TCP 端口
$ sudo nmap -sTU -O 192.168.2.13 ### 合并上面的
  1. windows
netstat -bano | more
netstat -bano | grep LISTENING
netstat -bano | findstr /R /C:"[LISTING]"

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + six =