「有地址不能上网」按层拆:链路 → 地址 → 路由 → 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看错命名空间。