转载请注明以下内容:

来源:公众号【网络技术干货圈】

作者:圈圈

ID:wljsghq

一、基础信息查询

1.1 IP地址信息

  • Windows

ipconfig /all 
  • Linux/macOS

ifconfig # 或 ip addr show 

 

1.2 路由表信息

  • Windows

route print 
  • Linux/macOS

netstat -r # 或 ip route show 

 

1.3 DNS信息

  • Windows

nslookup 
  • Linux/macOS

cat /etc/resolv.conf 

二、网络连接诊断

2.1 Ping测试

  • 通用

ping 目标地址 # 示例 ping 192.168.1.1 ping www.baidu.com 

 

2.2 Traceroute

  • Windows

tracert 目标地址 
  • Linux/macOS

traceroute 目标地址 

 

2.3 端口连通性测试

  • Windows

telnet 目标地址 端口号 # 示例 telnet 192.168.1.1 80 
  • Linux/macOS

nc -zv 目标地址 端口号 # 示例 nc -zv 192.168.1.1 80 

三、网络配置管理

3.1 释放与更新IP

  • Windows

ipconfig /release ipconfig /renew 
  • Linux/macOS

sudo dhclient -r sudo dhclient 

3.2 静态IP配置

  • Windows

netsh interface ip set address "以太网" static 192.168.1.100 255.255.255.0 192.168.1.1 
  • Linux

sudo nano /etc/network/interfaces # 添加以下内容 auto eth0 iface eth0 inet static     address 192.168.1.100     netmask 255.255.255.0     gateway 192.168.1.1 
  • macOS

sudo networksetup -setmanual "以太网" 192.168.1.100 255.255.255.0 192.168.1.1 

3.3 DNS配置

  • Windows

netsh interface ip set dns "以太网" static 8.8.8.8 
  • Linux

sudo nano /etc/resolv.conf # 添加以下内容 nameserver 8.8.8.8 
  • macOS

sudo networksetup -setdnsservers "以太网" 8.8.8.8 

四、高级网络工具

4.1 ARP表查询

  • Windows

arp -a 
  • Linux/macOS

arp -n 

 

4.2 网络连接状态

  • Windows

netstat -ano 
  • Linux/macOS

netstat -tuln 

4.3 抓包工具

  • 通用

tcpdump -i eth0 -w capture.pcap # 使用Wireshark分析 

五、网络服务管理

5.1 服务状态查询

  • Windows

sc query 
  • Linux

systemctl status 服务名 
  • macOS

sudo launchctl list | grep 服务名 

5.2 服务启停

  • Windows

net start 服务名 net stop 服务名 
  • Linux

sudo systemctl start 服务名 sudo systemctl stop 服务名 
  • macOS

sudo launchctl start 服务名 sudo launchctl stop 服务名 

六、网络安全相关

6.1 防火墙状态

  • Windows

netsh advfirewall show allprofiles 
  • Linux

sudo ufw status 

 

  • macOS

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate 

6.2 防火墙规则

  • Windows

netsh advfirewall firewall show rule name=all 
  • Linux

sudo iptables -L -n -v 
  • macOS

sudo pfctl -s rules 

七、网络性能测试

7.1 带宽测试

  • 通用

# 使用iperf工具 iperf -c 目标地址 

7.2 延迟测试

  • 通用

ping 目标地址 

7.3 数据包丢失测试

  • 通用

ping -c 100 目标地址 

八、其他实用命令

8.1 主机名查询

  • Windows

hostname 
  • Linux/macOS

hostname 

 

8.2 网络接口状态

  • Windows

netsh interface show interface 
  • Linux/macOS

ip link show 

 

8.3 路由追踪

  • Windows

pathping 目标地址 
  • Linux/macOS

mtr 目标地址 

这份速查表涵盖了从基础到高级的常用网络命令,适用于Windows、Linux和macOS系统。无论是日常维护还是故障排查,这些命令都能为您提供强大的支持。建议收藏并定期查阅,以提升网络管理效率。

 

文章信息

创建时间
2025-03-20
作者
郭铭心
是否所有人可见
所有人可见
最后修改日期
2025-03-20
点击数
34