# Windows 检查端口
telnet ip port
# Linux telnet 检查端口
telnet ip port
## 若报命令不存在时安装
sudo yum install telnet
## 成功
Trying 161.63.104.193...
Connected to 161.63.104.193.
Escape character is '^]'.
## 端口通但服务没启动
Trying 29.34.5.11...
telnet: connect to address 29.34.5.11: Connection refused
## 失败卡住
Trying 29.34.5.11...
# Linux crul 检查端口
curl localhost:port
## 成功是网页代码
## 端口通但服务没启动
curl: (7) Failed connect to localhost:port; Connection refused
## 失败卡住
# Linux ssh 检查端口
ssh -v -p port root@localhost
## 成功返回的是网页代码(一堆debug)
## 端口通但服务没启动
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to localhost [localhost] port port .
debug1: connect to address localhost port port : Connection refused
ssh: connect to host localhost port port : Connection refused
## 失败卡住
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to localhost [localhost] port port.
# 查看端口(参数说明:tcp udp 端口num LISTEN pid)
netstat -tunlp
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:27017 0.0.0.0:* LISTEN 19897/mongod
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 29589/java
tcp6 0 0 :::3306 :::* LISTEN 22248/mysqld
0.0.0.0 是对外开放 :::是IPV6版
127.0.0.1 是仅本机访问
# 查看系统发行版本
cat /etc/redhat-release
# CentOS 7 系统防火墙是否开启 (Active 是 dead 还是 run)
systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)