12网络命令
1.ping命令
ping www.woniuxy.com: 测试是否也和woniuxy.com的服务器连通,同时可以查看响应时间,及响应时间的分布情况
ping -i 3 www.baidu.com: 每3秒钟访问一次
ping -c 5 www.baidu.com: 一共发5个数字包
ping -f www.baidu.com: 快速发送ICMP数据包,进行压力测试
ping -f -c 200 www.baidu.com: 设定具体的发包数量,用于快速检测响应时间等数据
ping -s 1024 www.baidu.com: 设定每个ICMP数据包的大小
2.ip命令
ip addr:查看网卡及IP信息
ifconfig:同上
ip neigh:ARP协议,查看相邻计算机
arp -an:同上
ip link:查看网卡MAC地址等
ip -s link:查看网卡的收发数据包大小,RX:收,TX:发
ifconfig -s:同上
```c
[root@mycentos opt]# ifconfig -s
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
ens33 1500 184105 0 0 0 24513 0 0 0 BMRU
lo 65536 628 0 0 0 628 0 0 0 LRU
ip addr add 192.169.112.225:临时为ens33网卡添加一个IP地址,systemctl restart network后消失
[root@mycentos opt]# ip addr add 192.168.122.225/24 dev ens33
[root@mycentos opt]# ip addr
link/ether 00:0c:29:31:77:9d brd ff:ff:ff:ff:ff:ff
inet 192.168.234.188/24 brd 192.168.234.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet 192.168.122.225/24 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::4ad3:763f:4f83:1f5c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
可以看到多了ip地址,但是没有ping通
ifconfig ens33 192.168.112.225:临时修改IP地址
ip addr del 192.168.112.225/24 dev ens33:删除一个IP地址
查看路由IP地址:
ip route或roue或netstat -r或roue -n
ip route add default via 192.168.112.1 #为当前网络添加默认路由(网关)
route add default gw 192.168.112.1: #同上
ip route del default via 192.168.112.1 #删除路由
route del default gw 192.168.112.1
ip route flush cache #刷新路由表
ip link set en333 up #启动网卡
ifconfig ens33 up #同上,down表示关闭
ss -anl #端口占用情况
netstat -anlop #同上
u_str LISTEN 0 128 /run/dbus/system_bus_socket 18117 * 0
u_str LISTEN 0 100 public/pickup 19238 * 0
u_str LISTEN 0 100 public/cleanup 19242 * 0
u_str LISTEN 0 100 public/qmgr 19245 * 0
u_str LISTEN 0 100 public/flush 19267
| 老版本上的工具 | iproute2工具 | 说明 |
| -------------- | ------------------------- | --------------------------- |
| ifconfig | ip addr,ip link,ip -s | 地址及链接配置 |
| route | ip route | 路由表 |
| arp | ip neigh | 邻居 |
| iptunnel | ip tunnel | 通道 |
| nameif | ifrename,ip link set name | 网络接口更名 |
| ipmaddr | ip maddr | 多播 |
| netstat | ip -s,ss,ip route | 多种网络统计数据 |
| mii-tool | ethtool | 用mii与网卡自动协商工作状态 |
3.traceroute命令
Linux:
traceroute www.woniuxy.com
Windows:
tracert www.woniuxy.com
4.curl命令
curl http://www.woniuxy.com
curl -o woniuxy.html http://www.woniuxy.com #直接保存到文件
curl -O http://www.woniuxy.com/train/index.html #直接把最后的一段作为文件名
参考链接:http//www.ruanyifeng.com/blog/2019/09/curl-reference.html
5.wget命令
wget http://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
wget -P wordpress.tar.gz http://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
wget -c http://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz#断点续传
wget -b https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz:后台下载