Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)18k · #10688

linux-networking

Skill này làm gì

Skill này hướng dẫn thiết lập mạng Linux, gồm tường lửa với nftables và iptables, định tuyến, DNS và chẩn đoán sự cố kết nối. Nó dành cho quản trị viên hệ thống và nhà phát triển quản lý máy chủ Linux.

Khi nào nên dùng

  • ✓Khi bạn cần thiết lập quy tắc tường lửa trên máy chủ Linux.
  • ✓Khi một máy Linux không thể kết nối mạng, một máy chủ hoặc một tên DNS.
  • ✓Khi bạn muốn kiểm tra kết nối và dịch vụ nào đang lắng nghe trên máy chủ.

Liên kết skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/linux-networking/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/linux-networking/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Máy chủ Linux của tôi không phân giải được tên miền. Giúp tôi tìm nguyên nhân và thiết lập tường lửa chỉ cho phép SSH và HTTPS.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill giải thích luồng gói tin, khuyên dùng tường lửa mặc định chặn với các quy tắc cho phép rõ ràng, và đưa ra công cụ như ss và nft để kiểm tra và tải lại cài đặt.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

Default-deny là gì?

Nghĩa là mọi lưu lượng đều bị chặn trừ khi có quy tắc cho phép rõ ràng, điều này an toàn hơn cho máy chủ.

Vì sao dùng ss thay vì netstat?

Skill gọi netstat là lỗi thời và gợi ý ss để có thông tin kết nối nhanh hơn và chi tiết hơn.

Thay đổi tường lửa được áp dụng an toàn thế nào?

Skill gợi ý kiểm tra bộ quy tắc bằng nft list ruleset và tải lại nguyên tử bằng nft -f.

Chi tiết

Mô tả gốc của tác giả

Linux networking expert for iptables, nftables, routing, DNS, and network troubleshooting

repo: RightNow-AI/openfang

Độ phổ biến

Sao GitHub
18k
Vị trí xếp hạng
#10688
Giấy phép
Apache-2.0
Cập nhật
2/7/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự