安装whatportis Python包

whatportis库的github地址

pip3 install -i https://pypi.douban.com/simple  whatportis

查看MongoDB服务的默认端口号

$ whatportis mongodb
+---------+-------+----------+-----------------------+
| Name    |  Port | Protocol | Description           |
+---------+-------+----------+-----------------------+
| mongodb | 27017 |   tcp    | Mongo database system |
+---------+-------+----------+-----------------------+

查看Redis服务的默认端口号

$ whatportis redis
+-------+------+----------+---------------------------------------+
| Name  | Port | Protocol | Description                           |
+-------+------+----------+---------------------------------------+
| redis | 6379 |   tcp    | An advanced key-value cache and store |
+-------+------+----------+---------------------------------------+

查看22端口和3306端口是什么服务的默认端口

$ whatportis 22
+------+------+----------+---------------------------------+
| Name | Port | Protocol | Description                     |
+------+------+----------+---------------------------------+
| ssh  |  22  | tcp, udp | The Secure Shell (SSH) Protocol |
| ssh  |  22  |   sctp   | SSH                             |
+------+------+----------+---------------------------------+
$ whatportis 3306
+-------+------+----------+-------------+
| Name  | Port | Protocol | Description |
+-------+------+----------+-------------+
| mysql | 3306 | tcp, udp | MySQL       |
+-------+------+----------+-------------+

Q.E.D.


一只鹅啊