linux系统开启指定端口

作者:烟中隐约闪现 | 创建时间: 2023-05-28
通常在linux系统运维的时候需要测试某端口是否可访问,也就是测试端口的连通性...
linux系统开启指定端口

操作方法

测试主机linux主机是否安装该命令工具,出现以下提示说明nc命令未安装 [root@localhost ~]# nc -l 8888 -bash: nc: command not found

安装nc命令 root@localhost ~]# yum install -y nc

查看当前启动的端口 [root@localhost ~]# netstat -luntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1355/sshd tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2416/master tcp6       0      0 :::22                   :::*                    LISTEN      1355/sshd tcp6       0      0 ::1:25                  :::*                    LISTEN      2416/master udp        0      0 0.0.0.0:68              0.0.0.0:*                           10838/dhclient udp        0      0 0.0.0.0:8561            0.0.0.0:*                           10838/dhclient udp6       0      0 :::6388                 :::*                                10838/dhclient [root@localhost ~]# nc -l 8888

启动测试端口 [root@localhost ~]# nc -l 8888

确认端口是否已经有8888的端口 [root@localhost ~]# netstat -luntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1355/sshd tcp        0      0 0.0.0.0:8888            0.0.0.0:*               LISTEN      20289/nc tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2416/master tcp6       0      0 :::22                   :::*                    LISTEN      1355/sshd tcp6       0      0 :::8888                 :::*                    LISTEN      20289/nc tcp6       0      0 ::1:25                  :::*                    LISTEN      2416/master udp        0      0 0.0.0.0:68              0.0.0.0:*                           10838/dhclient udp        0      0 0.0.0.0:8561            0.0.0.0:*                           10838/dhclient udp6       0      0 :::6388                 :::*                                10838/dhclient

好了现在可以进行其他相关测试了

点击展开全文

更多推荐