[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F6E00VKWZF482A9BPW2RE9":3,"skill-same:01M6F6E00VKWZF482A9BPW2RE9":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":32,"commitSha":56,"skillDirectory":57,"forksCount":58,"repositoryHtmlUrl":59,"repositoryHomepageUrl":6,"ownerHtmlUrl":60,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":61,"install":62,"resources":75},"01M6F6E00VKWZF482A9BPW2RE9","firewall-config",null,"Configure iptables, nftables, and cloud firewalls. Implement network segmentation and traffic filtering. Use when securing network perimeters or implementing security zones.","boisenoise\u002Fskills-collections","boisenoise","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F193180?v=4","01M6CDBDQK6BDN55ZMA6B6PKBM","01M6CDBDVSJ3JPTBYN26FZ7TZK",13,"MIT","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-firewall-config\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"config","firewall","firewall config","2026","security","when","implementing","traffic","network segmentation","relevant","scripts","scope","critical","active","main","community","agent-skills","only","filtering","configure","devops-security","segmentation","network","license","assessment","2026-11-10 10:12:30",false,"---\nname: firewall-config\ndescription: Configure iptables, nftables, and cloud firewalls. Implement network\n  segmentation and traffic filtering. Use when securing network perimeters or implementing\n  security zones.\ncategory: security\nrisk: critical\nsource: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\nsource_repo: BagelHole\u002FDevOps-Security-Agent-Skills\nsource_type: community\ndate_added: '2026-09-20'\nlicense: MIT\nlicense_source: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE\ncompatibility: Requires the relevant security tooling (scanners, vault CLIs) and an\n  authorized scope for any active assessment. Docs-only; helper scripts and templates\n  not bundled.\nmetadata:\n  author: devops-skills\n  version: '1.0'\n---\n\n# Firewall Configuration\n\nConfigure host-based and cloud firewalls for network security.\n\n## When to Use This Skill\n\nUse this skill when:\n- Setting up a new server and need to restrict network access\n- Implementing network segmentation between application tiers\n- Configuring cloud security groups for AWS, GCP, or Azure resources\n- Migrating from iptables to nftables\n- Auditing existing firewall rules for compliance\n- Responding to a security incident requiring emergency network blocks\n\n## Prerequisites\n\n- Root or sudo access on Linux hosts\n- AWS CLI configured for cloud security groups\n- Understanding of TCP\u002FIP, ports, and protocols\n- Network diagram showing required traffic flows\n\nBefore writes, inventory the active firewall manager, IPv4\u002FIPv6 policy, container\u002FCNI rules and current management path. Preserve a verified rules backup, out-of-band console and tested rollback. Use an atomic reviewed ruleset where supported; do not flush NAT\u002Fmangle or an entire ruleset on a shared host. Examples are alternative local-lab sketches, not a script to run sequentially.\n\n## iptables\n\n### Basic Setup with Default Deny\n\n```bash\n# Preserve existing rules; do not flush production\u002Fcontainer-managed tables.\n# Build and validate a complete candidate offline, including management allows,\n# before atomically applying it within authorized scope.\n\n# Default policies - deny all inbound, allow outbound\niptables -P INPUT DROP\niptables -P FORWARD DROP\niptables -P OUTPUT ACCEPT\n\n# Allow established connections\niptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT\n\n# Allow loopback\niptables -A INPUT -i lo -j ACCEPT\n\n# Drop invalid packets\niptables -A INPUT -m conntrack --ctstate INVALID -j DROP\n\n# Allow SSH (restrict to management subnet)\niptables -A INPUT -p tcp --dport 22 -s 10.0.100.0\u002F24 -j ACCEPT\n\n# Allow HTTP\u002FHTTPS from anywhere\niptables -A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT\n\n# Allow ICMP (ping) with rate limiting\niptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1\u002Fs --limit-burst 4 -j ACCEPT\n\n# Log dropped packets (rate limited to avoid log flooding)\niptables -A INPUT -m limit --limit 5\u002Fmin -j LOG --log-prefix \"IPTABLES-DROP: \" --log-level 4\n\n# Save rules (Debian\u002FUbuntu)\niptables-save > \u002Fetc\u002Fiptables\u002Frules.v4\nip6tables-save > \u002Fetc\u002Fiptables\u002Frules.v6\n```\n\n### Anti-DDoS Rules\n\n```bash\n# SYN flood protection\n# Do not add a global SYN ACCEPT: it bypasses service\u002Fsource restrictions.\n# Apply a measured, service-specific limiter before the matching service allow;\n# a host firewall cannot guarantee mitigation of upstream bandwidth exhaustion.\n\n# Limit new connections per source IP\niptables -A INPUT -p tcp --dport 80 -m connlimit --connlimit-above 50 -j REJECT\n\n# Block port scanning (detect TCP flags abuse)\niptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP\niptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP\niptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP\niptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP\niptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP\n```\n\n### Application-Specific Rules\n\n```bash\n# Web server with database backend\n# Allow app servers to reach database (port 5432)\niptables -A INPUT -p tcp --dport 5432 -s 10.0.1.0\u002F24 -j ACCEPT\n\n# Allow monitoring (Prometheus node exporter)\niptables -A INPUT -p tcp --dport 9100 -s 10.0.200.0\u002F24 -j ACCEPT\n\n# DNS resolution\niptables -A INPUT -p udp --sport 53 -j ACCEPT\niptables -A INPUT -p tcp --sport 53 -j ACCEPT\n\n# NTP\niptables -A INPUT -p udp --sport 123 -j ACCEPT\n\n# Block specific IP (incident response)\niptables -I INPUT 1 -s 203.0.113.50 -j DROP\n```\n\n## UFW (Uncomplicated Firewall)\n\n```bash\n# Enable UFW with default deny\nufw default deny incoming\nufw default allow outgoing\n\n# Allow SSH from management network\nufw allow from 10.0.100.0\u002F24 to any port 22 proto tcp\n\n# Enable only after confirming this allow matches the actual management path.\nufw enable\n\n# Allow HTTP\u002FHTTPS\nufw allow 80\u002Ftcp\nufw allow 443\u002Ftcp\n\n# Allow specific application profile\nufw allow 'Nginx Full'\n\n# Rate limit SSH (max 6 connections in 30 seconds)\nufw limit ssh\n\n# Allow port range\nufw allow 8000:8080\u002Ftcp\n\n# Deny specific IP\nufw deny from 203.0.113.50\n\n# Check status\nufw status verbose\nufw status numbered\n\n# Delete a rule by number\nufw delete 3\n\n# Application profiles\nufw app list\nufw app info 'Nginx Full'\n```\n\n## nftables\n\n### Illustrative Server Configuration\n\nNot a complete router\u002Fcontainer policy: the forward chain drops traffic, so the DNAT example below also needs narrowly scoped forwarding and IP forwarding configuration. Validate required ICMPv6 control\u002Ferror traffic for the actual network before use. The late SYN limiter does not affect earlier accepted HTTP\u002FHTTPS packets.\n\n```bash\n#!\u002Fusr\u002Fsbin\u002Fnft -f\nflush ruleset\n\n# Define variables\ndefine LAN = 10.0.0.0\u002F16\ndefine MGMT = 10.0.100.0\u002F24\ndefine MONITOR = 10.0.200.0\u002F24\n\ntable inet filter {\n  # Rate limiting set\n  set rate_limit {\n    type ipv4_addr\n    flags dynamic,timeout\n    timeout 1m\n  }\n\n  chain input {\n    type filter hook input priority 0; policy drop;\n\n    # Connection tracking\n    ct state established,related accept\n    ct state invalid drop\n\n    # Loopback\n    iif \"lo\" accept\n\n    # ICMP and ICMPv6\n    ip protocol icmp icmp type { echo-request, destination-unreachable, time-exceeded } limit rate 10\u002Fsecond accept\n    ip6 nexthdr icmpv6 icmpv6 type { echo-request, nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert, destination-unreachable, packet-too-big, time-exceeded, parameter-problem } accept\n\n    # SSH from management only\n    tcp dport 22 ip saddr $MGMT accept\n\n    # HTTP\u002FHTTPS from anywhere\n    tcp dport { 80, 443 } accept\n\n    # Prometheus metrics from monitoring subnet\n    tcp dport 9100 ip saddr $MONITOR accept\n\n    # Rate limit new connections\n    tcp flags syn limit rate over 25\u002Fsecond burst 50 packets drop\n\n    # Log dropped traffic\n    log prefix \"nft-drop: \" level warn limit rate 5\u002Fminute\n  }\n\n  chain forward {\n    type filter hook forward priority 0; policy drop;\n  }\n\n  chain output {\n    type filter hook output priority 0; policy accept;\n\n    # Optional: restrict outbound to known destinations\n    # tcp dport { 80, 443, 53 } accept\n    # udp dport { 53, 123 } accept\n    # ct state established,related accept\n    # drop\n  }\n}\n\n# NAT table for port forwarding\ntable ip nat {\n  chain prerouting {\n    type nat hook prerouting priority -100;\n    # Forward port 8080 to internal app server\n    tcp dport 8080 dnat to 10.0.1.10:8080\n  }\n\n  chain postrouting {\n    type nat hook postrouting priority 100;\n    oifname \"eth0\" masquerade\n  }\n}\n```\n\n### nftables Management Commands\n\n```bash\n# Load configuration\nnft -f \u002Fetc\u002Fnftables.conf\n\n# List all rules\nnft list ruleset\n\n# List specific table\nnft list table inet filter\n\n# Add a rule dynamically\nnft add rule inet filter input tcp dport 8443 accept\n\n# Insert rule at position\nnft insert rule inet filter input position 5 ip saddr 10.0.50.0\u002F24 tcp dport 3306 accept\n\n# Delete a rule by handle\nnft -a list chain inet filter input  # show handles\nnft delete rule inet filter input handle 15\n\n# Monitor in real time\nnft monitor\n```\n\n## AWS Security Groups\n\n### Terraform Configuration\n\n```hcl\n# Web tier security group\nresource \"aws_security_group\" \"web\" {\n  name_prefix = \"web-sg-\"\n  vpc_id      = aws_vpc.main.id\n  description = \"Security group for web servers\"\n\n  ingress {\n    description = \"HTTPS from internet\"\n    from_port   = 443\n    to_port     = 443\n    protocol    = \"tcp\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  ingress {\n    description = \"HTTP redirect\"\n    from_port   = 80\n    to_port     = 80\n    protocol    = \"tcp\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  egress {\n    description = \"All outbound\"\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  tags = {\n    Name        = \"web-sg\"\n    Environment = \"production\"\n    ManagedBy   = \"terraform\"\n  }\n}\n\n# App tier - only accepts traffic from web tier\nresource \"aws_security_group\" \"app\" {\n  name_prefix = \"app-sg-\"\n  vpc_id      = aws_vpc.main.id\n  description = \"Security group for application servers\"\n\n  ingress {\n    description     = \"HTTP from web tier\"\n    from_port       = 8080\n    to_port         = 8080\n    protocol        = \"tcp\"\n    security_groups = [aws_security_group.web.id]\n  }\n\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n}\n\n# Database tier - only accepts from app tier\nresource \"aws_security_group\" \"db\" {\n  name_prefix = \"db-sg-\"\n  vpc_id      = aws_vpc.main.id\n  description = \"Security group for database servers\"\n\n  ingress {\n    description     = \"PostgreSQL from app tier\"\n    from_port       = 5432\n    to_port         = 5432\n    protocol        = \"tcp\"\n    security_groups = [aws_security_group.app.id]\n  }\n\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n}\n```\n\n### AWS CLI Commands\n\n```bash\n# Create security group\naws ec2 create-security-group \\\n  --group-name web-sg \\\n  --description \"Web server SG\" \\\n  --vpc-id vpc-0abc123\n\n# Add inbound rule\naws ec2 authorize-security-group-ingress \\\n  --group-id sg-0abc123 \\\n  --protocol tcp --port 443 \\\n  --cidr 0.0.0.0\u002F0\n\n# Add rule referencing another security group\naws ec2 authorize-security-group-ingress \\\n  --group-id sg-0db456 \\\n  --protocol tcp --port 5432 \\\n  --source-group sg-0app789\n\n# Remove a rule\naws ec2 revoke-security-group-ingress \\\n  --group-id sg-0abc123 \\\n  --protocol tcp --port 22 \\\n  --cidr 0.0.0.0\u002F0\n\n# Describe rules\naws ec2 describe-security-group-rules \\\n  --filters Name=group-id,Values=sg-0abc123\n```\n\n## Firewall Rule Audit Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# firewall-audit.sh - Audit current firewall rules for common issues\n\necho \"=== Firewall Audit Report ===\"\necho \"Date: $(date -u +%Y-%m-%dT%H:%M:%SZ)\"\necho \"Host: $(hostname)\"\necho \"\"\n\n# Check if firewall is active\nif command -v nft &>\u002Fdev\u002Fnull; then\n    echo \"--- nftables rules ---\"\n    nft list ruleset\nelif command -v iptables &>\u002Fdev\u002Fnull; then\n    echo \"--- iptables rules ---\"\n    iptables -L -n -v --line-numbers\nfi\n\necho \"\"\necho \"--- Open ports ---\"\nss -tlnp\n\necho \"\"\necho \"--- Potential issues ---\"\n\n# Check for overly permissive rules\nif iptables -L INPUT -n 2>\u002Fdev\u002Fnull | grep -q \"0.0.0.0\u002F0.*dpt:22\"; then\n    echo \"WARNING: SSH (port 22) open to 0.0.0.0\u002F0 - restrict to management subnet\"\nfi\n\nif iptables -L INPUT -n 2>\u002Fdev\u002Fnull | grep -q \"0.0.0.0\u002F0.*dpt:3306\"; then\n    echo \"CRITICAL: MySQL (port 3306) open to 0.0.0.0\u002F0\"\nfi\n\nif iptables -L INPUT -n 2>\u002Fdev\u002Fnull | grep -q \"0.0.0.0\u002F0.*dpt:5432\"; then\n    echo \"CRITICAL: PostgreSQL (port 5432) open to 0.0.0.0\u002F0\"\nfi\n\n# Check default policies\nDEFAULT_INPUT=$(iptables -L INPUT 2>\u002Fdev\u002Fnull | head -1 | grep -oP 'policy \\K\\w+')\nif [ \"$DEFAULT_INPUT\" = \"ACCEPT\" ]; then\n    echo \"CRITICAL: Default INPUT policy is ACCEPT - should be DROP\"\nfi\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| Locked out of SSH | Rule order or default deny applied before allow | Use out-of-band console access; add SSH allow rule first |\n| Rules lost after reboot | Rules not persisted | Install `iptables-persistent` or save to `\u002Fetc\u002Fnftables.conf` |\n| Docker bypasses iptables | Docker modifies iptables FORWARD chain | Review the Docker backend and supported policy chain; disabling Docker firewall management can break isolation\u002FNAT and is not a routine fix |\n| nftables and iptables conflict | Both running simultaneously | Identify whether iptables uses the nft backend and which manager owns rules; do not remove packages or flush blindly |\n| AWS SG rule limit reached | Max 60 inbound rules per SG | Use prefix lists or consolidate CIDR ranges |\n| Legitimate traffic blocked | Rule ordering issue | Place more specific allow rules before general deny rules |\n\n## Best Practices\n\n- Default deny policy on all chains\n- Minimal rule sets - only open what is required\n- Regular rule audits (monthly minimum)\n- Log denied traffic for security monitoring\n- Document all rules with descriptions and ticket references\n- Use connection tracking for stateful inspection\n- Rate limit inbound connections to prevent DDoS\n- Separate management traffic from application traffic\n- Test rule changes in staging before production\n- Keep persistent backups of working rule sets\n\n## Related Skills\n\n- linux-hardening (`linux-hardening`) - System security\n- aws-vpc (`aws-vpc`) - AWS networking\n- zero-trust (`zero-trust`) - Identity-based access patterns\n- vpn-setup (`vpn-setup`) - Secure tunnel configuration\n\n## Limitations\n\n- Apply guidance only within authorized scope; test destructive steps in non-production first.\n- Docs-only import: upstream scripts and templates not bundled.\n\n### Example\n\n```bash\n# Read-only first: inventory before any active step.\nwhich \u003Ctool> && \u003Ctool> --help | head -n 20\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n","# Firewall Configuration\n\nConfigure host-based and cloud firewalls for network security.\n\n## When to Use This Skill\n\nUse this skill when:\n- Setting up a new server and need to restrict network access\n- Implementing network segmentation between application tiers\n- Configuring cloud security groups for AWS, GCP, or Azure resources\n- Migrating from iptables to nftables\n- Auditing existing firewall rules for compliance\n- Responding to a security incident requiring emergency network blocks\n\n## Prerequisites\n\n- Root or sudo access on Linux hosts\n- AWS CLI configured for cloud security groups\n- Understanding of TCP\u002FIP, ports, and protocols\n- Network diagram showing required traffic flows\n\nBefore writes, inventory the active firewall manager, IPv4\u002FIPv6 policy, container\u002FCNI rules and current management path. Preserve a verified rules backup, out-of-band console and tested rollback. Use an atomic reviewed ruleset where supported; do not flush NAT\u002Fmangle or an entire ruleset on a shared host. Examples are alternative local-lab sketches, not a script to run sequentially.\n\n## iptables\n\n### Basic Setup with Default Deny\n\n```bash\n# Preserve existing rules; do not flush production\u002Fcontainer-managed tables.\n# Build and validate a complete candidate offline, including management allows,\n# before atomically applying it within authorized scope.\n\n# Default policies - deny all inbound, allow outbound\niptables -P INPUT DROP\niptables -P FORWARD DROP\niptables -P OUTPUT ACCEPT\n\n# Allow established connections\niptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT\n\n# Allow loopback\niptables -A INPUT -i lo -j ACCEPT\n\n# Drop invalid packets\niptables -A INPUT -m conntrack --ctstate INVALID -j DROP\n\n# Allow SSH (restrict to management subnet)\niptables -A INPUT -p tcp --dport 22 -s 10.0.100.0\u002F24 -j ACCEPT\n\n# Allow HTTP\u002FHTTPS from anywhere\niptables -A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT\n\n# Allow ICMP (ping) with rate limiting\niptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1\u002Fs --limit-burst 4 -j ACCEPT\n\n# Log dropped packets (rate limited to avoid log flooding)\niptables -A INPUT -m limit --limit 5\u002Fmin -j LOG --log-prefix \"IPTABLES-DROP: \" --log-level 4\n\n# Save rules (Debian\u002FUbuntu)\niptables-save > \u002Fetc\u002Fiptables\u002Frules.v4\nip6tables-save > \u002Fetc\u002Fiptables\u002Frules.v6\n```\n\n### Anti-DDoS Rules\n\n```bash\n# SYN flood protection\n# Do not add a global SYN ACCEPT: it bypasses service\u002Fsource restrictions.\n# Apply a measured, service-specific limiter before the matching service allow;\n# a host firewall cannot guarantee mitigation of upstream bandwidth exhaustion.\n\n# Limit new connections per source IP\niptables -A INPUT -p tcp --dport 80 -m connlimit --connlimit-above 50 -j REJECT\n\n# Block port scanning (detect TCP flags abuse)\niptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP\niptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP\niptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP\niptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP\niptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP\n```\n\n### Application-Specific Rules\n\n```bash\n# Web server with database backend\n# Allow app servers to reach database (port 5432)\niptables -A INPUT -p tcp --dport 5432 -s 10.0.1.0\u002F24 -j ACCEPT\n\n# Allow monitoring (Prometheus node exporter)\niptables -A INPUT -p tcp --dport 9100 -s 10.0.200.0\u002F24 -j ACCEPT\n\n# DNS resolution\niptables -A INPUT -p udp --sport 53 -j ACCEPT\niptables -A INPUT -p tcp --sport 53 -j ACCEPT\n\n# NTP\niptables -A INPUT -p udp --sport 123 -j ACCEPT\n\n# Block specific IP (incident response)\niptables -I INPUT 1 -s 203.0.113.50 -j DROP\n```\n\n## UFW (Uncomplicated Firewall)\n\n```bash\n# Enable UFW with default deny\nufw default deny incoming\nufw default allow outgoing\n\n# Allow SSH from management network\nufw allow from 10.0.100.0\u002F24 to any port 22 proto tcp\n\n# Enable only after confirming this allow matches the actual management path.\nufw enable\n\n# Allow HTTP\u002FHTTPS\nufw allow 80\u002Ftcp\nufw allow 443\u002Ftcp\n\n# Allow specific application profile\nufw allow 'Nginx Full'\n\n# Rate limit SSH (max 6 connections in 30 seconds)\nufw limit ssh\n\n# Allow port range\nufw allow 8000:8080\u002Ftcp\n\n# Deny specific IP\nufw deny from 203.0.113.50\n\n# Check status\nufw status verbose\nufw status numbered\n\n# Delete a rule by number\nufw delete 3\n\n# Application profiles\nufw app list\nufw app info 'Nginx Full'\n```\n\n## nftables\n\n### Illustrative Server Configuration\n\nNot a complete router\u002Fcontainer policy: the forward chain drops traffic, so the DNAT example below also needs narrowly scoped forwarding and IP forwarding configuration. Validate required ICMPv6 control\u002Ferror traffic for the actual network before use. The late SYN limiter does not affect earlier accepted HTTP\u002FHTTPS packets.\n\n```bash\n#!\u002Fusr\u002Fsbin\u002Fnft -f\nflush ruleset\n\n# Define variables\ndefine LAN = 10.0.0.0\u002F16\ndefine MGMT = 10.0.100.0\u002F24\ndefine MONITOR = 10.0.200.0\u002F24\n\ntable inet filter {\n  # Rate limiting set\n  set rate_limit {\n    type ipv4_addr\n    flags dynamic,timeout\n    timeout 1m\n  }\n\n  chain input {\n    type filter hook input priority 0; policy drop;\n\n    # Connection tracking\n    ct state established,related accept\n    ct state invalid drop\n\n    # Loopback\n    iif \"lo\" accept\n\n    # ICMP and ICMPv6\n    ip protocol icmp icmp type { echo-request, destination-unreachable, time-exceeded } limit rate 10\u002Fsecond accept\n    ip6 nexthdr icmpv6 icmpv6 type { echo-request, nd-neighbor-solicit, nd-neighbor-advert, nd-router-solicit, nd-router-advert, destination-unreachable, packet-too-big, time-exceeded, parameter-problem } accept\n\n    # SSH from management only\n    tcp dport 22 ip saddr $MGMT accept\n\n    # HTTP\u002FHTTPS from anywhere\n    tcp dport { 80, 443 } accept\n\n    # Prometheus metrics from monitoring subnet\n    tcp dport 9100 ip saddr $MONITOR accept\n\n    # Rate limit new connections\n    tcp flags syn limit rate over 25\u002Fsecond burst 50 packets drop\n\n    # Log dropped traffic\n    log prefix \"nft-drop: \" level warn limit rate 5\u002Fminute\n  }\n\n  chain forward {\n    type filter hook forward priority 0; policy drop;\n  }\n\n  chain output {\n    type filter hook output priority 0; policy accept;\n\n    # Optional: restrict outbound to known destinations\n    # tcp dport { 80, 443, 53 } accept\n    # udp dport { 53, 123 } accept\n    # ct state established,related accept\n    # drop\n  }\n}\n\n# NAT table for port forwarding\ntable ip nat {\n  chain prerouting {\n    type nat hook prerouting priority -100;\n    # Forward port 8080 to internal app server\n    tcp dport 8080 dnat to 10.0.1.10:8080\n  }\n\n  chain postrouting {\n    type nat hook postrouting priority 100;\n    oifname \"eth0\" masquerade\n  }\n}\n```\n\n### nftables Management Commands\n\n```bash\n# Load configuration\nnft -f \u002Fetc\u002Fnftables.conf\n\n# List all rules\nnft list ruleset\n\n# List specific table\nnft list table inet filter\n\n# Add a rule dynamically\nnft add rule inet filter input tcp dport 8443 accept\n\n# Insert rule at position\nnft insert rule inet filter input position 5 ip saddr 10.0.50.0\u002F24 tcp dport 3306 accept\n\n# Delete a rule by handle\nnft -a list chain inet filter input  # show handles\nnft delete rule inet filter input handle 15\n\n# Monitor in real time\nnft monitor\n```\n\n## AWS Security Groups\n\n### Terraform Configuration\n\n```hcl\n# Web tier security group\nresource \"aws_security_group\" \"web\" {\n  name_prefix = \"web-sg-\"\n  vpc_id      = aws_vpc.main.id\n  description = \"Security group for web servers\"\n\n  ingress {\n    description = \"HTTPS from internet\"\n    from_port   = 443\n    to_port     = 443\n    protocol    = \"tcp\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  ingress {\n    description = \"HTTP redirect\"\n    from_port   = 80\n    to_port     = 80\n    protocol    = \"tcp\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  egress {\n    description = \"All outbound\"\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  tags = {\n    Name        = \"web-sg\"\n    Environment = \"production\"\n    ManagedBy   = \"terraform\"\n  }\n}\n\n# App tier - only accepts traffic from web tier\nresource \"aws_security_group\" \"app\" {\n  name_prefix = \"app-sg-\"\n  vpc_id      = aws_vpc.main.id\n  description = \"Security group for application servers\"\n\n  ingress {\n    description     = \"HTTP from web tier\"\n    from_port       = 8080\n    to_port         = 8080\n    protocol        = \"tcp\"\n    security_groups = [aws_security_group.web.id]\n  }\n\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n}\n\n# Database tier - only accepts from app tier\nresource \"aws_security_group\" \"db\" {\n  name_prefix = \"db-sg-\"\n  vpc_id      = aws_vpc.main.id\n  description = \"Security group for database servers\"\n\n  ingress {\n    description     = \"PostgreSQL from app tier\"\n    from_port       = 5432\n    to_port         = 5432\n    protocol        = \"tcp\"\n    security_groups = [aws_security_group.app.id]\n  }\n\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n}\n```\n\n### AWS CLI Commands\n\n```bash\n# Create security group\naws ec2 create-security-group \\\n  --group-name web-sg \\\n  --description \"Web server SG\" \\\n  --vpc-id vpc-0abc123\n\n# Add inbound rule\naws ec2 authorize-security-group-ingress \\\n  --group-id sg-0abc123 \\\n  --protocol tcp --port 443 \\\n  --cidr 0.0.0.0\u002F0\n\n# Add rule referencing another security group\naws ec2 authorize-security-group-ingress \\\n  --group-id sg-0db456 \\\n  --protocol tcp --port 5432 \\\n  --source-group sg-0app789\n\n# Remove a rule\naws ec2 revoke-security-group-ingress \\\n  --group-id sg-0abc123 \\\n  --protocol tcp --port 22 \\\n  --cidr 0.0.0.0\u002F0\n\n# Describe rules\naws ec2 describe-security-group-rules \\\n  --filters Name=group-id,Values=sg-0abc123\n```\n\n## Firewall Rule Audit Script\n\n```bash\n#!\u002Fbin\u002Fbash\n# firewall-audit.sh - Audit current firewall rules for common issues\n\necho \"=== Firewall Audit Report ===\"\necho \"Date: $(date -u +%Y-%m-%dT%H:%M:%SZ)\"\necho \"Host: $(hostname)\"\necho \"\"\n\n# Check if firewall is active\nif command -v nft &>\u002Fdev\u002Fnull; then\n    echo \"--- nftables rules ---\"\n    nft list ruleset\nelif command -v iptables &>\u002Fdev\u002Fnull; then\n    echo \"--- iptables rules ---\"\n    iptables -L -n -v --line-numbers\nfi\n\necho \"\"\necho \"--- Open ports ---\"\nss -tlnp\n\necho \"\"\necho \"--- Potential issues ---\"\n\n# Check for overly permissive rules\nif iptables -L INPUT -n 2>\u002Fdev\u002Fnull | grep -q \"0.0.0.0\u002F0.*dpt:22\"; then\n    echo \"WARNING: SSH (port 22) open to 0.0.0.0\u002F0 - restrict to management subnet\"\nfi\n\nif iptables -L INPUT -n 2>\u002Fdev\u002Fnull | grep -q \"0.0.0.0\u002F0.*dpt:3306\"; then\n    echo \"CRITICAL: MySQL (port 3306) open to 0.0.0.0\u002F0\"\nfi\n\nif iptables -L INPUT -n 2>\u002Fdev\u002Fnull | grep -q \"0.0.0.0\u002F0.*dpt:5432\"; then\n    echo \"CRITICAL: PostgreSQL (port 5432) open to 0.0.0.0\u002F0\"\nfi\n\n# Check default policies\nDEFAULT_INPUT=$(iptables -L INPUT 2>\u002Fdev\u002Fnull | head -1 | grep -oP 'policy \\K\\w+')\nif [ \"$DEFAULT_INPUT\" = \"ACCEPT\" ]; then\n    echo \"CRITICAL: Default INPUT policy is ACCEPT - should be DROP\"\nfi\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| Locked out of SSH | Rule order or default deny applied before allow | Use out-of-band console access; add SSH allow rule first |\n| Rules lost after reboot | Rules not persisted | Install `iptables-persistent` or save to `\u002Fetc\u002Fnftables.conf` |\n| Docker bypasses iptables | Docker modifies iptables FORWARD chain | Review the Docker backend and supported policy chain; disabling Docker firewall management can break isolation\u002FNAT and is not a routine fix |\n| nftables and iptables conflict | Both running simultaneously | Identify whether iptables uses the nft backend and which manager owns rules; do not remove packages or flush blindly |\n| AWS SG rule limit reached | Max 60 inbound rules per SG | Use prefix lists or consolidate CIDR ranges |\n| Legitimate traffic blocked | Rule ordering issue | Place more specific allow rules before general deny rules |\n\n## Best Practices\n\n- Default deny policy on all chains\n- Minimal rule sets - only open what is required\n- Regular rule audits (monthly minimum)\n- Log denied traffic for security monitoring\n- Document all rules with descriptions and ticket references\n- Use connection tracking for stateful inspection\n- Rate limit inbound connections to prevent DDoS\n- Separate management traffic from application traffic\n- Test rule changes in staging before production\n- Keep persistent backups of working rule sets\n\n## Related Skills\n\n- linux-hardening (`linux-hardening`) - System security\n- aws-vpc (`aws-vpc`) - AWS networking\n- zero-trust (`zero-trust`) - Identity-based access patterns\n- vpn-setup (`vpn-setup`) - Secure tunnel configuration\n\n## Limitations\n\n- Apply guidance only within authorized scope; test destructive steps in non-production first.\n- Docs-only import: upstream scripts and templates not bundled.\n\n### Example\n\n```bash\n# Read-only first: inventory before any active step.\nwhich \u003Ctool> && \u003Ctool> --help | head -n 20\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n",{"name":5,"risk":30,"source":48,"license":14,"category":22,"metadata":49,"date_added":52,"description":7,"source_repo":53,"source_type":33,"compatibility":54,"license_source":55},"https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills",{"author":50,"version":51},"devops-skills","1.0","2026-09-20","BagelHole\u002FDevOps-Security-Agent-Skills","Requires the relevant security tooling (scanners, vault CLIs) and an authorized scope for any active assessment. Docs-only; helper scripts and templates not bundled.","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE","7bf2279c8a65758319526a721d5c4b75683aec9c","skills\u002Fantigravity-firewall-config",3,"https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections","https:\u002F\u002Fgithub.com\u002Fboisenoise","2026-11-14 14:18:11",{"source":8,"skillName":5,"commands":63,"prompt":73,"zipAvailable":74},[64,67,70],{"tool":65,"command":66},"npx","npx skills add boisenoise\u002Fskills-collections --skill firewall-config",{"tool":68,"command":69},"bunx","bunx skills add boisenoise\u002Fskills-collections --skill firewall-config",{"tool":71,"command":72},"pnpm","pnpm dlx skills add boisenoise\u002Fskills-collections --skill firewall-config","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-firewall-config\u002FSKILL.md",true,[],[77,86,94,103,111,119],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":81,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":85},"01M7B6HREHB53EHGGVZND7DDXN","scrapely-scrape","Collect web data with ready-made Scrape.ly scrapers: Google Maps places, Amazon products, LinkedIn jobs, reviews, social posts. Use when the user wants structured data from a site.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-scrapely-scrape\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-scrapely-scrape\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":85},"01M7B6GDNNN4HE662KA6KPF7GW","lumify-odds","Lumify's hosted sports MCP\u002FREST API for sportsbook odds, line-movement history, public betting splits, and player props across MLB, NFL, NBA, NHL, soccer, tennis, NCAAF, NCAAB. Read-only market data.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-lumify-odds\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-lumify-odds\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":98,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":102},"01M743PZMJW2GEKG5J199GPSK7","sync-lipsync","Lip-sync an existing video of a real person to new audio or a typed script with sync. labs through its hosted MCP server, quoting the cost and waiting for approval first.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-sync-lipsync\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-sync-lipsync\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":107,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":102},"01M743MMN3CKTJVNRSZMB684E5","music-for-robots","Optional music-inspired creative exercise for multimodal agents. Ingests an unquantized acoustic MP3 composition by Michael Luchtan (Music For Robots) into a private temporary directory, analyzing microtiming and texture to inspire creative writing, brainstorming, or technical tasks.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-music-for-robots\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-music-for-robots\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":115,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":102},"01M743KC2GN5WE11BSTWSSWD8B","imagera-media","Generate or edit images, video clips, voiceovers and music through the hosted Imagera MCP server, quoting the credit cost and getting approval before each paid call.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-imagera-media\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-imagera-media\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":123,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":102},"01M743HDJNZQA8A4VT68NWGWQJ","deja-history","Search this machine's past AI coding sessions across Claude Code, Codex, Cursor, Gemini CLI and thirty-nine other agents before editing, debugging, or denying something exists.","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-deja-history\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fboisenoise\u002Fskills-collections\u002Fblob\u002Fmain\u002Fskills\u002Fantigravity-deja-history\u002FSKILL.md",[],[]]