Skip to content

Instantly share code, notes, and snippets.

@yude
Created February 28, 2024 14:31
Show Gist options
  • Save yude/d350a3f13e6701f5e36c8b1797e33e58 to your computer and use it in GitHub Desktop.
Save yude/d350a3f13e6701f5e36c8b1797e33e58 to your computer and use it in GitHub Desktop.
nftables で、特定のサブネット以外のトラフィックをマスカレードする
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0;
}
chain forward {
type filter hook forward priority 0;
}
chain output {
type filter hook output priority 0;
}
}
table ip nat {
chain prerouting {
type nat hook prerouting priority 0;
}
chain postrouting {
type nat hook postrouting priority 100;
ip daddr != {10.20.0.0/16} oifname "eth0" masquerade
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment