一、网络测试
参考:Linux 网络设置(ifconfig、route、traceroute、netstat、ss、nslookup、dig) | 航行学园 (voycn.com)
查看网络属性
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| ifconfig ip
hostname hostname <newname>
route
ss [options]
$ ss -anpt
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| netstat [options]
$ netstat -anpt
netstat -ltunp netstat -ltn netstat -lun netstat -lx
|
测试网络连接
1 2 3 4 5 6 7 8 9 10 11 12
| $ ping www.google.com $ ping www.baidu.com
$ traceroute www.baidu.com $ mtr www.baidu.com
$ nslookup www.google.com $ dig @8.8.8.8 baidu.com
|
二、网络配置
1 2 3 4 5
| $ systemctl restart network
vim /etc/resolv.conf
vim /etc/hosts
|
三、网络访问
1.wget
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| wget [选项] URL资源
wget -O myfile.zip -c -b http://www.example.com/testfile.zip
wget -i dowload.txt
wget --limit-rate=300k http://www.example.com/testfile.zip
wget -Q 10m -i dowload.txt
|
1 2 3 4 5 6 7
|
wget --http-user=USER --http-password=PASS http://www.example.com/testfile.zip
|
1 2 3 4 5 6 7 8 9 10
|
wget -r -nd -np -A pdf,png http://www.example.com/path1/path2/
|
2.curl
1 2 3 4 5 6 7 8 9 10 11
|
curl [-o 自定义文件名|-O] http://www.example.com/index.html
curl -O -C - http://www.example.com/testfile.zip
curl -O -C - --limit-rate 500k --max-filesize 10m http://www.example.com/testfile.zip
|
1 2 3 4 5 6 7 8
|
curl --trace-ascii output.txt http://www.example.com
curl -L http://a.com
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
curl -X POST \ -H 'Content-Type:application/json' \ -H 'Accept-Language: en-US' \ -H 'Secret-Message: xyzzy' \ http://www.example.com/test
curl -c cookies.txt -b cookies.txt http://example.com
curl -u 'user[:password]' https://www.example.com
curl -A 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Mobile Safari/537.36' https://www.example.com
curl -e '源网址' https://www.example.com
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
curl -d '参数' http://www.example.com/test
curl -d '{"user":"zhangsan", "password":"123456"}' -H 'Content-Type:application/json' http://www.example.com/login
curl -d '@requestData.txt' -H 'Content-Type:application/json' http://www.example.com/login
curl http://www.example.com/login?user=zhansan&password=123456
|
1 2 3 4 5 6
|
curl -F 'file=@文件;filename=me.png;type=image/png' https://www.example.com/test
|
实例
1.VMware虚拟机全局代理
2.设置静态IP