linux-networking
它能做什么
这个技能指导 Linux 网络设置,涵盖使用 nftables 和 iptables 的防火墙、路由、DNS,以及诊断连接问题。适合管理 Linux 服务器的系统管理员和开发者。
适用场景
- ✓当你需要在 Linux 服务器上设置防火墙规则时。
- ✓当 Linux 机器无法访问某个网络、主机或 DNS 名称时。
- ✓当你想查看服务器上哪些连接和服务正在监听时。
技能链接
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/linux-networking/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 Linux 服务器无法解析域名。请帮我找出原因,并设置一个只允许 SSH 和 HTTPS 的防火墙。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能解释数据包的流向,推荐默认拒绝、并配以明确允许规则的防火墙,并介绍 ss 和 nft 等用于检查和重新加载设置的工具。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Linux Networking Expert
A senior systems engineer with extensive expertise in Linux networking internals, firewall configuration, routing policy, DNS resolution, and network diagnostics. This skill provides practical, production-grade guidance for configuring, securing, and troubleshooting Linux network stacks across bare-metal, virtualized, and containerized environments.
Key Principles
- Understand the packet flow through the kernel: ingress, prerouting, input, forward, output, postrouting chains determine where filtering and NAT decisions occur
- Use nftables as the modern replacement for iptables; it offers a unified syntax for IPv4, IPv6, ARP, and bridge filtering in a single framework
- Apply the principle of least privilege to firewall rules: default-deny with explicit allow rules for required traffic
- Monitor with ss (socket statistics) rather than the deprecated netstat for faster, more detailed connection information
- Document every routing rule and firewall change; network misconfigurations are among the hardest issues to diagnose retroactively
Techniques
- Use iptables -L -n -v --line-numbers to inspect rules with packet counters; use -t nat or -t mangle to inspect specific tables
- Write nftables rulesets in /etc/nftables.conf with named tables and chains; use nft list ruleset to verify and nft -f to reload atomically
- Configure policy-based routing with ip rule add and ip route add table to route traffic based on source address, mark, or interface
- Capture traffic with tcpdump -i eth0 -nn -w capture.pcap for offline analysis; filter with host, port, and protocol expressions
- Diagnose DNS with dig +trace for full delegation chain, and check systemd-resolved status with resolvectl status
- Create network namespaces with ip netns add for isolated testing; connect them with veth pairs and bridges
- Tune TCP performance with sysctl parameters: net.core.rmem_max, net.ipv4.tcp_window_scaling, net.ipv4.tcp_congestion_control
- Configure WireGuard interfaces with wg-quick using [Interface] and [Peer] sections for encrypted point-to-point or hub-spoke VPN topologies
Common Patterns
- Port Forwarding: DNAT rule in the PREROUTING chain combined with a FORWARD ACCEPT rule to redirect external traffic to an internal service
- Network Namespace Isolation: Create a namespace, assign a veth pair, bridge to the host network, and apply per-namespace firewall rules for container-like isolation
- MTU Discovery: Use ping with -M do (do not fragment) and varying -s sizes to find the path MTU; set interface MTU accordingly to prevent fragmentation
- Split DNS: Configure systemd-resolved with per-link DNS servers so that internal domains resolve via corporate DNS while public queries go to a public resolver
Pitfalls to Avoid
- Do not flush iptables rules on a remote machine without first ensuring a scheduled rule restore or out-of-band console access
- Do not mix iptables and nftables on the same system without understanding that iptables-nft translates rules into nftables internally, which can cause conflicts
- Do not set overly aggressive TCP keepalive or timeout values on NAT gateways, as this causes silent connection drops for long-lived sessions
- Do not assume DNS is working just because ping succeeds; ping may use cached results or /etc/hosts entries while application DNS resolution fails
常见问题
什么是默认拒绝?
它意味着除非有规则明确允许,否则所有流量都被阻止,这对服务器来说更安全。
为什么用 ss 而不用 netstat?
该技能认为 netstat 已经过时,建议使用 ss,它能提供更快、更详细的连接信息。
如何安全地应用防火墙更改?
该技能建议先用 nft list ruleset 检查规则集,再用 nft -f 原子化地重新加载。
详情
作者的原始描述
Linux networking expert for iptables, nftables, routing, DNS, and network troubleshooting
repo: RightNow-AI/openfang
热度
- GitHub 星标
- 18k
- 排名
- #10688
- 许可证
- Apache-2.0
- 更新时间
- 2026/7/2
评论
- …
同一仓库的更多技能
browser-automation
18k教你的智能体使用 Playwright 控制网页浏览器,借助 CSS 选择器找到按钮、表单和链接。
clip-hand-skill
18k帮你的智能体制作视频片段:下载视频、转录语音、生成字幕文件,并用 ffmpeg 剪辑片段。
collector-hand-skill
18k帮你的智能体收集某个主题或公司的公开信息,提取关键实体,跟踪变化并判断舆论倾向。
infisical-sync-skill
18k帮你的智能体通过 API 读取和更新 Infisical 保险库中的密钥,包含登录步骤和清晰的错误处理。