gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
Hello there! Could you show me a example of a nftables rule that will allow me to accept…
- User
Hello there! Could you show me a example of a nftables rule that will allow me to accept a rate limited icmp ping request, allow via a vmap established and related traffic, drop invalid packets, allow ports 80, 8000, 22 tcp, and finally drop all other traffic?
- Assistant
Certainly! Below is an example of an
nftablesconfiguration that implements your requirements:#!/usr/sbin/nft -f table inet filter { chain input { type filter hook input priority 0; policy drop; # Allow loopback traffic iif lo accept # Drop invalid packets ct state invalid drop # Accept established and related traffic ct state established,related accept # Allow rate-limited ICMP ping requests (4 packets per second) ip protocol icmp limit rate 4/second accept # Allow TCP traffic on ports 22, 80, and 8000 tcp dport { 22, 80, 8000 } accept } chain forward { type filter hook forward priority 0; policy drop; } chain output { type filter hook output priority 0; policy accept; } }