本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)18k · #10688

linux-networking

できること

このスキルは、nftablesやiptablesによるファイアウォール、ルーティング、DNS、接続の問題の診断など、Linuxのネットワーク設定を案内します。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に貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/linux-networking/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

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
よくある質問

デフォルト拒否とは何ですか?

許可するルールが明示されていない通信はすべて遮断することです。サーバーにとって安全な方法です。

netstatではなくssを使うのはなぜですか?

このスキルは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

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル