zoukankan      html  css  js  c++  java
  • linux下查看端口的占用情况

    netstat -tln
    linkin@OpenSuse:~> netstat -tln
    --------------------------------------------------------------------------------
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address State
    tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
    tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
    tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
    tcp 0 0 0.0.0.0:5001 0.0.0.0:* LISTEN
    tcp 0 0 :::111 :::* LISTEN
    tcp 0 0 ::1:631 :::* LISTEN
    tcp 0 0 ::1:25 :::* LISTEN
    tcp 0 0 :::445 :::* LISTEN
    tcp 0 0 :::56362 :::* LISTEN
    tcp 0 0 :::139 :::* LISTEN
    Netstat后面的意思
    ·Proto显示连接使用的协议。
    ·RefCnt表示连接到本套接口上的进程号。
    ·Types显示套接口的类型。
    ·State显示套接口当前的状态。
    ·Path表示连接到套接口的其它进程使用的路径名
    Netstat -tln 命令是用来查看linux的端口使用情况,
    netstat -a 查看所有的服务端口
    netstat -an | grep 端口号 来检验下是不是已经打开了某某端口
    service xxx start 或者 /etc/init.d/xxx start是开启xxx某端口
    iptables -A INPUT --dport xxx -j DROP
    iptables -A OUTPUT --dport xxx -j DROP是关闭xxx端口

    当我们使用 netstat -apn 查看网络连接的时候,会发现很多类似下面的内容:
     
      Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
     
      tcp 0 52 218.104.81.152:7710 211.100.39.250:29488 ESTABLISHED 6111/1
     
      显示这台服务器开放了7710端口,那么这个端口属于哪个程序呢?我们可以使用 lsof -i :7710 命令来查询:
     
      COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
     
      sshd 1990 root 3u IPv4 4836 TCP *:7710 (LISTEN) 网管联盟bitsCN@com
     
      这样,我们就知道了7710端口是属于sshd程序的。

  • 相关阅读:
    kafka学习默认端口号9092
    kafka搜索介绍
    进程线程区别
    linux下的mysql修改默认编码
    [LeetCode] #19 Remove Nth Node From End of List
    [LeetCode] #18 4Sum
    [LeetCode] #17 Letter Combinations of a Phone Number
    [LeetCode] #16 3Sum Closest
    编程之美2015 #1 2月29日
    编程之美2015 #2 回文字符序列
  • 原文地址:https://www.cnblogs.com/potu/p/2831187.html
Copyright © 2011-2022 走看看