Linux 网络配置:iproute2、DNS 与连通性排障

「有地址不能上网」按层拆:链路 → 地址 → 路由 → DNS → 防火墙 → 对端 。工具以 ip/ss 为主。

源码锚点

路径 / 手册 作用
man ip 地址/路由/链路
man ss 套接字
man resolvectl systemd-resolved
/etc/resolv.conf DNS(可能被托管)

调用链

#mermaid-svg-cZJOShJWs3U7n1Gh{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-cZJOShJWs3U7n1Gh .error-icon{fill:#552222;}#mermaid-svg-cZJOShJWs3U7n1Gh .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-cZJOShJWs3U7n1Gh .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-cZJOShJWs3U7n1Gh .marker{fill:#333333;stroke:#333333;}#mermaid-svg-cZJOShJWs3U7n1Gh .marker.cross{stroke:#333333;}#mermaid-svg-cZJOShJWs3U7n1Gh svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-cZJOShJWs3U7n1Gh p{margin:0;}#mermaid-svg-cZJOShJWs3U7n1Gh .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-cZJOShJWs3U7n1Gh .cluster-label text{fill:#333;}#mermaid-svg-cZJOShJWs3U7n1Gh .cluster-label span{color:#333;}#mermaid-svg-cZJOShJWs3U7n1Gh .cluster-label span p{background-color:transparent;}#mermaid-svg-cZJOShJWs3U7n1Gh .label text,#mermaid-svg-cZJOShJWs3U7n1Gh span{fill:#333;color:#333;}#mermaid-svg-cZJOShJWs3U7n1Gh .node rect,#mermaid-svg-cZJOShJWs3U7n1Gh .node circle,#mermaid-svg-cZJOShJWs3U7n1Gh .node ellipse,#mermaid-svg-cZJOShJWs3U7n1Gh .node polygon,#mermaid-svg-cZJOShJWs3U7n1Gh .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-cZJOShJWs3U7n1Gh .rough-node .label text,#mermaid-svg-cZJOShJWs3U7n1Gh .node .label text,#mermaid-svg-cZJOShJWs3U7n1Gh .image-shape .label,#mermaid-svg-cZJOShJWs3U7n1Gh .icon-shape .label{text-anchor:middle;}#mermaid-svg-cZJOShJWs3U7n1Gh .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-cZJOShJWs3U7n1Gh .rough-node .label,#mermaid-svg-cZJOShJWs3U7n1Gh .node .label,#mermaid-svg-cZJOShJWs3U7n1Gh .image-shape .label,#mermaid-svg-cZJOShJWs3U7n1Gh .icon-shape .label{text-align:center;}#mermaid-svg-cZJOShJWs3U7n1Gh .node.clickable{cursor:pointer;}#mermaid-svg-cZJOShJWs3U7n1Gh .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-cZJOShJWs3U7n1Gh .arrowheadPath{fill:#333333;}#mermaid-svg-cZJOShJWs3U7n1Gh .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-cZJOShJWs3U7n1Gh .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-cZJOShJWs3U7n1Gh .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-cZJOShJWs3U7n1Gh .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-cZJOShJWs3U7n1Gh .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-cZJOShJWs3U7n1Gh .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-cZJOShJWs3U7n1Gh .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-cZJOShJWs3U7n1Gh .cluster text{fill:#333;}#mermaid-svg-cZJOShJWs3U7n1Gh .cluster span{color:#333;}#mermaid-svg-cZJOShJWs3U7n1Gh div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-cZJOShJWs3U7n1Gh .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-cZJOShJWs3U7n1Gh rect.text{fill:none;stroke-width:0;}#mermaid-svg-cZJOShJWs3U7n1Gh .icon-shape,#mermaid-svg-cZJOShJWs3U7n1Gh .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-cZJOShJWs3U7n1Gh .icon-shape p,#mermaid-svg-cZJOShJWs3U7n1Gh .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-cZJOShJWs3U7n1Gh .icon-shape .label rect,#mermaid-svg-cZJOShJWs3U7n1Gh .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-cZJOShJWs3U7n1Gh .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-cZJOShJWs3U7n1Gh .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-cZJOShJWs3U7n1Gh :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 应用 connect
路由决策
出接口
邻居/ARP/ND
对端
DNS 查询
解析器

重点知识

bash 复制代码
ip -br link
ip -br addr
ip route
ss -lntup
ping -c 3 网关
ping -c 3 1.1.1.1
resolvectl status 2>/dev/null || cat /etc/resolv.conf

静态与 DHCP

NetworkManager、systemd-networkd、ifupdown 三选一为主,避免多网络管理器互踩。

常见坑

  • 有 IPv6 无 IPv4 路由导致应用超时。
  • DNS 通但 HTTP 被防火墙拦。
  • 容器/ip netns 看错命名空间。
相关推荐
新时代牛马1 小时前
Linux systemd 服务管理:从unit 文件到systemctl 启停与排障
linux·服务器·网络
隐擎fox2 小时前
网络传输安全剖析:WebRTC 本地真实 IP 泄漏机制(STUN/TURN)与 Python 防护检测实战
网络·网络协议·tcp/ip·安全·webrtc
回忆2012初秋2 小时前
DBX:一个现代化的轻量级、跨平台的开源数据库管理工具
大数据·服务器·网络
fengkai45452 小时前
七、华为云网络综合实验 & 运维类及其他服务总结
服务器·开发语言·php
对讲机数码科普2 小时前
# 室内弱覆盖场景专网通信优化方案:建筑结构、频段适配与组网布局的系统分析
网络
为思念酝酿的痛2 小时前
应用层协议HTTP
网络·网络协议·http
JeJe同学2 小时前
Linux远程服务器网络访问优化:使用SSH反向端口转发共享本地HTTP代理
服务器·网络·ssh
光电笑映2 小时前
Linux 线程同步与互斥:锁的本质、条件变量与信号量的底层原理
linux·运维·服务器·开发语言·c++
rcms152702692183 小时前
Advanced Energy 31512411-338直流电源
网络