第8章 网络管理
网络管理
netstat lsof route ping host wget sftp scp
1 查询网络服务和端口
netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),masquerade 连接,多播成员 (Multicast Memberships) 等等。
列出所有端口 (包括监听和未监听的):
1 | netstat -a |
列出所有 tcp 端口:
1 | netstat -at |
列出所有有监听的服务状态:
1 | netstat -l |
使用netstat工具查询端口:
1 | $netstat -antp | grep 6379 |
查询7902端口现在运行什么程序:
- 查询使用该端口的进程的PID
1 | $lsof -i:7902 |
- 查到30294,使用ps工具查询进程详情:
1 | $ps -fe | grep 30294 |
2 网络路由
查看路由状态:
1 | $route -n |
发送ping包到地址IP:
1 | $ping IP |
探测前往地址IP的路由路径:
1 | $traceroute IP |
DNS查询,寻找域名domain对应的IP:
1 | $host domain |
反向DNS查询:
1 | $host IP |
3 镜像下载
直接下载文件或者网页:
1 | wget url |
常用选项:
1 | –limit-rate :下载限速 |
axel工具真好用
4 ftp sftp lftp ssh
SSH登陆:
1 | $ssh ID@host |
ssh登陆远程服务器host,ID为用户名。
ftp/sftp文件传输:
1 | $sftp ID@host |
登陆服务器host,ID为用户名。sftp登陆后,可以使用下面的命令进一步操作:
1 | get filename # 下载文件 |
lftp同步文件夹(类似rsync工具):
1 | lftp -u user:pass host |
5 网络复制
将本地localpath指向的文件上传到远程主机的path路径:
1 | $scp localpath ID@host:path |
以ssh协议,遍历下载path路径下的整个文件系统,到本地的localpath:
1 | $scp -r ID@site:path localpath |
6 网络性能
ping baidu.com
traceroute
mtr baidu.com
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Estom的博客!









