深入网络操作命令
nslookup
# 可以查询域名指定类型的解析记录
nslookup www.baidu.com
# 出现解析不了域名的情况
修改/etc/resolv.conf文件,添加dns解析服务器
nmap
# 扫描端口开放情况
nmap www.baidu.com
strace
# 跟踪命令的调用情况,显示socket连接和open哪些配置文件
[root@VM-4-3-centos ~]# strace -e open,connect,socket nslookup www.baidu.com
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libdns.so.1102", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/liblwres.so.160", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libbind9.so.160", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libisccfg.so.160", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libisc.so.169", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libgssapi_krb5.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libkrb5.so.3", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libk5crypto.so.3", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libcom_err.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libcrypto.so.10", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libidn.so.11", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libGeoIP.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libxml2.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libkrb5support.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libkeyutils.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/proc/filesystems", O_RDONLY) = 3
open("/etc/pki/tls/legacy-settings", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libdns.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libisc.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
socket(AF_UNIX, SOCK_STREAM, 0) = 3
open("/proc/self/task/14433/comm", O_RDWR) = 3
open("/proc/self/task/14434/comm", O_RDWR) = 3
open("/proc/self/task/14435/comm", O_RDWR) = 6
open("/usr/share/locale/en_US.UTF-8/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libdst.cat", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/pki/tls/openssl.cnf", O_RDONLY) = 6
open("/etc/resolv.conf", O_RDONLY) = 6
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 6
Server: 183.60.83.19
Address: 183.60.83.19#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 153.3.238.110
Name: www.a.shifen.com
Address: 153.3.238.102
traceroute
[root@VM-4-3-centos ~]# traceroute www.baidu.com
traceroute to www.baidu.com (153.3.238.102), 30 hops max, 60 byte packets
1 * * *
2 * * *
3 * * *
4 10.200.66.125 (10.200.66.125) 3.569 ms 10.200.66.81 (10.200.66.81) 2.604 ms 10.200.66.89 (10.200.66.89) 3.488 ms
5 10.162.5.110 (10.162.5.110) 1.614 ms 220.196.197.162 (220.196.197.162) 2.658 ms 10.162.5.110 (10.162.5.110) 1.653 ms
6 220.196.197.161 (220.196.197.161) 3.234 ms 3.014 ms 220.196.197.169 (220.196.197.169) 3.189 ms
7 211.95.32.109 (211.95.32.109) 3.481 ms 211.95.32.69 (211.95.32.69) 3.241 ms 211.95.32.125 (211.95.32.125) 5.259 ms
8 219.158.17.18 (219.158.17.18) 9.426 ms 9.373 ms 10.216 ms
9 153.3.228.130 (153.3.228.130) 8.300 ms 8.186 ms 8.567 ms
10 153.37.96.242 (153.37.96.242) 14.538 ms 12.000 ms 11.995 ms
11 182.61.255.184 (182.61.255.184) 9.254 ms 182.61.255.194 (182.61.255.194) 9.369 ms 182.61.255.186 (182.61.255.186) 9.258 ms
12 182.61.255.171 (182.61.255.171) 11.197 ms 11.275 ms 182.61.255.167 (182.61.255.167) 9.293 ms
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *
18 * * *
19 * * *
20 * * *
21 * * *
22 * * *
23 * * *
24 * * *
25 * * *
26 * * *
27 * * *
28 * * *
29 * * *
30 * * *
mtr
# 快速的查看路由情况,一般看最后两个节点
[root@VM-4-3-centos ~]# mtr www.baidu.com
lsof
# 快速查看进程打开了哪些文件
[root@VM-4-3-centos ~]# lsof |grep nginx|grep log
nginx 27660 root 2w REG 253,1 3550 1186589 /var/log/nginx/error.log
nginx 27660 root 4w REG 253,1 3550 1186589 /var/log/nginx/error.log
nginx 27660 root 5w REG 253,1 9437 1186588 /var/log/nginx/access.log
nginx 27661 nginx 2w REG 253,1 3550 1186589 /var/log/nginx/error.log
nginx 27661 nginx 4w REG 253,1 3550 1186589 /var/log/nginx/error.log
nginx 27661 nginx 5w REG 253,1 9437 1186588 /var/log/nginx/access.log
nginx 27662 nginx 2w REG 253,1 3550 1186589 /var/log/nginx/error.log
nginx 27662 nginx 4w REG 253,1 3550 1186589 /var/log/nginx/error.log
nginx 27662 nginx 5w REG 253,1 9437 1186588 /var/log/nginx/access.log
# 查看网络连接
[root@VM-4-3-centos ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 27660 root 6u IPv4 62447989 0t0 TCP *:http (LISTEN)
nginx 27661 nginx 6u IPv4 62447989 0t0 TCP *:http (LISTEN)
nginx 27662 nginx 6u IPv4 62447989 0t0 TCP *:http (LISTEN)
标签:操作命令,ms,网络,nginx,深入,RDONLY,CLOEXEC,lib64,open
From: https://www.cnblogs.com/louvice/p/17676095.html