Efficiently test if a port is open on Linux?

后端 未结 14 1061
面向向阳花
面向向阳花 2020-12-02 04:02

From a bash script how can I quickly find out whether a port 445 is open/listening on a server.

I have tried a couple of options, but I want something q

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 04:15

    tcping is a great tool with a very low overhead.It also has a timeout argument to make it quicker:

    [root@centos_f831dfb3 ~]# tcping 10.86.151.175 22 -t 1
    10.86.151.175 port 22 open.
    [root@centos_f831dfb3 ~]# tcping 10.86.150.194 22 -t 1
    10.86.150.194 port 22 user timeout.
    [root@centos_f831dfb3 ~]# tcping 1.1.1.1 22 -t 1
    1.1.1.1 port 22 closed.
    

提交回复
热议问题