1.查看哪些端口被打开
netstat -anp
[root@iZ2vc5xk901ftf2vfscwc1Z docker_lnmp]# netstat -anp
Active Internet connections (servers and established)
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 1089/sshd
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 1449/docker-proxy
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN 1469/docker-proxy
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 1413/docker-proxy
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1431/docker-proxy
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 2321/docker-proxy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2510/docker-proxy
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 1507/docker-proxy
tcp 0 0 172.25.125.164:60636 100.100.30.25:80 ESTABLISHED 1052/AliYunDun
tcp 0 0 172.25.125.164:22 118.112.58.206:13314 ESTABLISHED 2250/sshd: root [pr
tcp 0 0 172.25.125.164:56912 100.100.0.42:443 TIME_WAIT -
tcp6 0 0 :::15672 :::* LISTEN 1455/docker-proxy
tcp6 0 0 :::5672 :::* LISTEN 1476/docker-proxy
tcp6 0 0 :::25672 :::* LISTEN 1419/docker-proxy
tcp6 0 0 :::3306 :::* LISTEN 1436/docker-proxy
tcp6 0 0 :::6379 :::* LISTEN 2327/docker-proxy
tcp6 0 0 :::80 :::* LISTEN 2515/docker-proxy
tcp6 0 0 :::4369 :::* LISTEN 1513/docker-proxy
udp 0 0 127.0.0.1:323 0.0.0.0:* 764/chronyd
udp 0 0 172.25.125.164:68 172.25.127.253:67 ESTABLISHED 828/NetworkManager
udp6 0 0 ::1:323 :::* 764/chronyd
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 20739 1/systemd /var/run/docker.sock
unix 2 [ ACC ] STREAM LISTENING 20742 1/systemd /var/run/.heim_org.h5l.kcm-socket
unix 2 [ ACC ] STREAM LISTENING 20745 1/systemd /run/dbus/system_bus_socket
unix 2 [ ACC ] SEQPACKET LISTENING 17930 1/systemd /run/systemd/coredump
2.查看tcp/tcp6哪些端口被打开
netstat -ntl
[root@iZ2vc5xk901ftf2vfscwc1Z docker_lnmp]# netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN
tcp6 0 0 :::15672 :::* LISTEN
tcp6 0 0 :::5672 :::* LISTEN
tcp6 0 0 :::25672 :::* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::6379 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::4369 :::* LISTEN
3.打开端口
//打开23端口
nc -lp 23 &
//查看是否打开23端口
netstat -an | grep 23