关于 network
面向网络工程任务的技能,用于排查连接问题和配置网络基础设施。内容涵盖 DNS、SSL/TLS、负载均衡、流量分析及性能诊断的命令示例与指导。
主要功能
- 01连接与端口检查
- 02DNS 和 SSL/TLS 调试
- 03负载均衡配置指导
- 04数据包捕获与流量分析
- 05常见网络问题诊断
适用场景
- 01排查 API 请求超时
- 02处理 DNS 或证书错误
- 03配置负载均衡器
- 04检查网络延迟和数据包
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ htlin222/ dotfiles --skill network安装后在 Claude Code 中输入/network确认已加载。
详细介绍
网络工程
排查连接问题并配置网络基础设施。
使用场景
- 连接问题
- 负载均衡器设置
- SSL/TLS 问题
- DNS 调试
- 网络性能
诊断命令
连接测试
# Basic connectivity
ping -c 4 host.example.com
traceroute host.example.com
# Port check
nc -zv host.example.com 443
telnet host.example.com 80
# DNS lookup
dig +short example.com
dig +trace example.com
nslookup -type=MX example.com
# HTTP testing
curl -v https://api.example.com/health
curl -w "@curl-format.txt" -o /dev/null -s https://example.com
curl-format.txt
time_namelookup: %{time_namelookup}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_redirect: %{time_redirect}s\n
time_starttransfer: %{time_starttransfer}s\n
----------\n
time_total: %{time_total}s\n
SSL/TLS 调试
# Check certificate
openssl s_client -connect example.com:443 -servername example.com
# Verify certificate chain
openssl s_client -connect example.com:443 -showcerts
# Check expiry
echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates
# Test specific TLS version
curl --tlsv1.2 --tls-max 1.2 https://example.com
负载均衡器配置
Nginx
upstream backend {
least_conn;
server backend1.example.com:8080 weight=5;
server backend2.example.com:8080 weight=3;
server backend3.example.com:8080 backup;
keepalive 32;
}
server {
listen 443 ssl http2;
server_name api.example.com;
ssl_certificate /etc/ssl/certs/api.crt;
ssl_certificate_key /etc/ssl/private/api.key;
location / {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 5s;
proxy_read_timeout 60s;
}
location /health {
access_log off;
return 200 "OK";
}
}
流量分析
# Capture packets
tcpdump -i eth0 -w capture.pcap port 443
# Read capture
tcpdump -r capture.pcap -n
# Filter by host
tcpdump -i any host 10.0.0.1 and port 80
# Show HTTP requests
tcpdump -i any -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
常见问题
| 症状 | 检查项 | 修复方法 |
|---|---|---|
| 连接被拒绝 | 端口是否开放?服务是否运行? | 启动服务,开放防火墙 |
| 连接超时 | 防火墙?路由? | 检查安全组和路由 |
| SSL 错误 | 证书是否有效?证书链是否完整? | 续订证书,修复证书链 |
| DNS 解析失败 | 解析器?记录是否存在? | 检查 DNS 配置,添加记录 |
| 响应缓慢 | 延迟?带宽? | 优化路由,提升容量 |
示例
输入:“API 调用超时” **操作:**测试连接、检查 DNS、验证 SSL、分析延迟
输入:“设置负载均衡器” **操作:**配置 nginx/HAProxy、添加运行状况检查、测试故障转移
评论
支持 Markdown