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 看错命名空间。
相关推荐
吴建旭 智宅焕8 小时前
智能家居全国交付中执行端能力跃迁的架构设计:从标准装调到交付专家的系统化路径
网络·网络协议·智能家居
lzx_00210 小时前
Linux 进程(三) 从进程状态到僵尸进程、孤儿进程
linux·服务器
Eyfcom11 小时前
〖全球化架构 05〗跨国网络专线优化:QUIC 协议与 SD-WAN 在跨境传输中的实战
网络·架构·跨境物流快递系统·全球化架构
FlightYe11 小时前
音视频修炼之容器与协议(四):RTSP详解
android·linux·ffmpeg·音视频·dash
Dream Cosmos12 小时前
传输层协议之UDP
网络·网络协议·udp
刘马想放假12 小时前
CANviz 使用指南|Linux 安装、DBC 解码、实时曲线与 J1939 实战
linux·python·websocket
kloc14 小时前
聊天室项目入口网关子服务的实现
linux·c++
GeW14 小时前
深圳APEC峰会倒计时:数据库与Linux运维的"隐形考场"
linux
梦到啥说啥15 小时前
Linux网络编程:UDP网络协议
linux·网络协议·udp
鸿蒙开发爱好者16 小时前
下班后做的小工具和小游戏,我把它们整理成了 WyanHub
网络·人工智能·职场和发展·个人开发