Hello to all this script is based on an old script of openwrt of @dlakelan
it allows to identify only what we need
I kept only the essential by debugging it as I go along
I'll show you a great example of what can do
I would like to push the thing by being able to block the list which presents like a geofilter if possible thank you
for launch this script create in usr /share/nftables.d/ruleset-post/dopam.nft
then root@OpenWrt:~# /etc/init.d/firewall restart
Automatically including '/usr/share/nftables.d/ruleset-post/dopam.nft'
then launch nft list ruleset
define ipconsole = {192.168.2.160} # ajoute ta console
table inet dopam # autorise
flush table inet dopam # nettoie les regles
table inet dopam {
### change pour choisir ce que tu veux
set udp_meter4 {typeof ip saddr . ip daddr . udp sport . udp dport
timeout 5m
}
chain dopam {
type filter hook forward priority 0; policy accept;
ip protocol udp ip daddr $ipconsole
ip protocol udp ip saddr $ipconsole
#choisi ton protocole pour ce que tu veux
ip protocol udp add @udp_meter4 {ip saddr . ip daddr . udp sport . udp dport}
}
}
#### lancer la commande nft list ruleset
you can see in this example
table inet dopam {
set udp_meter4 {
typeof ip saddr . ip daddr . udp sport . udp dport
size 65535
flags dynamic,timeout
timeout 5m
elements = { 192.168.2.160 . 185.34.107.128 . 3074 . 3074 timeout 5m expires 3m29s420ms,
185.34.107.128 . 192.168.2.160 . 3074 . 3074 timeout 5m expires 4m42s690ms,
185.34.107.129 . 192.168.2.160 . 3075 . 3074 timeout 5m expires 4m42s850ms,
173.199.105.13 . 192.168.2.160 . 34080 . 3074 timeout 5m expires 4m58s820ms,
173.199.105.8 . 192.168.2.160 . 37040 . 3074 timeout 5m expires 3m34s460ms,
173.45.168.71 . 192.168.2.160 . 35091 . 3076 timeout 5m expires 4m53s210ms,
the list is longer I have shortened it
but the goal is to be able to identify in my case servers and then to be able to block them by iprange
other example for see only the port
root@OpenWrt:~# nft list ruleset
table inet dopam {
set udp_meter4 {
typeof udp sport . udp dport
size 65535
flags dynamic,timeout
timeout 5m
elements = { 3074 . 3074 timeout 5m expires 4m59s310ms,
3075 . 3074 timeout 5m expires 4m59s660ms,
9308 . 9308 timeout 5m expires 3m30s590ms,
3478 . 9308 timeout 5m expires 3m29s630ms,
3479 . 9308 timeout 5m expires 3m29s810ms,
56188 . 21116 timeout 5m expires 3m29s230ms,
64748 . 21116 timeout 5m expires 3m29s20ms,
64749 . 21116 timeout 5m expires 3m29s30ms,
21116 . 56188 timeout 5m expires 3m29s360ms,
9308 . 3478 timeout 5m expires 3m29s450ms,
9308 . 3479 timeout 5m expires 3m29s630ms,
443 . 50106 timeout 5m expires 4m43s640ms,
50106 . 443 timeout 5m expires 4m43s620ms,
54014 . 443 timeout 5m expires 3m38s980ms,
21116 . 64748 timeout 5m expires 3m29s220ms,
21116 . 64749 timeout 5m expires 3m29s300ms,
443 . 54014 timeout 5m expires 3m39s }