Help me to create a script that generates the basic servers

@segal72 @moeller0 @dlakelan

I found the way to find the location of the servers thanks to dscptag of dlakelan in ruleset-post but I would like to use just the option udp meter4 and something which generates the server at the beginning of game at the time of the connection to the server on line of the game call of duty that works very well it is genial but I would like to launch it automatically has each game via ssh to see if the waiters evolve or change, I put you in link the script of dlakelan and the handling to carry out this turn of pass :wink:

Translated with www.DeepL.com/Translator (free version)


define udpbulkport = {51413}
define tcpbulkport = {51413,6881-6889}
define vidconfports = {10000,3478-3479,8801-8802,19302-19309,5938,53}
define realtime4 = {192.168.109.1} # example, just add all your game console here
define realtime6 = {fd90::129a} ## example only replace with game console
define lowpriolan4 = {192.168.109.2} # example, add your low priority lan machines here
define lowpriolan6 = {fd90::129a} ## example, add your low priority lan ipv6 PUBLIC addr here

define ackrate = 300

define downrate = 15000 # kbits/sec ... CHANGE ME
define uprate = 15000 # kbits/sec ... CHANGE ME

define first500ms = 937500 # downrate * 500/8
define first10s = 18750000 # downrate * 10000/8

define wan = "eth1.2" # change me


table inet dscptag # forward declaration so the next command always works

flush table inet dscptag # clear all the rules

table inet dscptag {

    map priomap { type dscp : classid ;
        elements =  {ef : 1:11, cs5 : 1:11, cs6 : 1:11, cs7 : 1:11,
                    cs4 : 1:12, af41 : 1:12, af42 : 1:12,
                    cs2 : 1:14 , cs1 : 1:15, cs0 : 1:13}
    }


    set xfst4ack { typeof ip daddr . ip saddr . tcp dport . tcp sport
        timeout 5m
    }
    set fast4ack { typeof ip daddr . ip saddr . tcp dport . tcp sport
        timeout 5m
    }
    set med4ack { typeof ip daddr . ip saddr . tcp dport . tcp sport
        timeout 5m
    }
    set slow4ack { typeof ip daddr . ip saddr . tcp dport . tcp sport
        timeout 5m
    }
    set udp_meter4 {typeof ip saddr . ip daddr . udp sport . udp dport
        timeout 5m
    }
    set udp_meter6 {typeof ip6 saddr . ip6 daddr . udp sport . udp dport
        timeout 5m
    }
    set slowtcp4 {typeof ip saddr . ip daddr . tcp sport . tcp dport
        timeout 5m
    }
    set slowtcp6 {typeof ip6 saddr . ip6 daddr . tcp sport . tcp dport
        timeout 5m
    }

    chain drop995 {
        numgen random mod 1000 < 995 drop
    }
    chain drop95 {
        numgen random mod 100 < 95 drop
    }
    chain drop50 {
        numgen random mod 100 < 50 drop
    }


    chain dscptag {
        type filter hook forward priority 0; policy accept;

        # wash all the DSCP to begin with ... you can comment this out
        ip dscp set cs0 counter
        ip6 dscp set cs0 counter

        ip protocol udp udp sport $udpbulkport ip dscp set cs1
        ip6 nexthdr udp udp sport $udpbulkport ip6 dscp set cs1

        ip protocol udp udp dport $udpbulkport ip dscp set cs1
        ip6 nexthdr udp udp dport $udpbulkport ip6 dscp set cs1

        ip protocol tcp tcp sport $tcpbulkport ip dscp set cs1
        ip6 nexthdr tcp tcp sport $tcpbulkport ip6 dscp set cs1
        ip protocol tcp tcp dport $tcpbulkport ip dscp set cs1
        ip6 nexthdr tcp tcp dport $tcpbulkport ip6 dscp set cs1

        ## ack limit rate to about 150 pps by decimating the quantity of pure acks being sent
        ip protocol tcp tcp flags & ack == ack meta length < 100 add @xfst4ack {ip daddr . ip saddr . tcp dport . tcp sport limit rate over 30000/second} jump drop995 
        ip protocol tcp tcp flags & ack == ack meta length < 100 add @fast4ack {ip daddr . ip saddr . tcp dport . tcp sport limit rate over 3000/second} jump drop95
        ip protocol tcp tcp flags & ack == ack meta length < 100 add @med4ack {ip daddr . ip saddr . tcp dport . tcp sport limit rate over 300/second} jump drop50
        ip protocol tcp tcp flags & ack == ack meta length < 100 add @slow4ack {ip daddr . ip saddr . tcp dport . tcp sport limit rate over 300/second} jump drop50
        ## for almost everyone we won't send more than 150-400 acks/second

        ip protocol udp udp dport $vidconfports ip dscp set cs4
        ip6 nexthdr udp udp dport $vidconfports ip6 dscp set cs4

        ip protocol udp ip daddr $realtime4 ip dscp set cs5
        ip protocol udp ip saddr $realtime4 ip dscp set cs5

        ip6 nexthdr udp ip6 daddr $realtime6 ip6 dscp set cs5
        ip6 nexthdr udp ip6 saddr $realtime6 ip6 dscp set cs5

        ip protocol udp ip daddr $lowpriolan4 ip dscp set cs2
        ip protocol udp ip saddr $lowpriolan4 ip dscp set cs2

        ip6 nexthdr udp ip6 daddr $lowpriolan6 ip6 dscp set cs2
        ip6 nexthdr udp ip6 saddr $lowpriolan6 ip6 dscp set cs2

        #downgrade udp going faster than 450 pps, probably not realtime traffic
        ip protocol udp ip dscp > cs2 add @udp_meter4 {ip saddr . ip daddr . udp sport . udp dport limit rate over 450/second} counter ip dscp set cs2
        ip6 nexthdr udp ip6 dscp > cs2 add @udp_meter6 {ip6 saddr . ip6 daddr . udp sport . udp dport limit rate over 450/second} counter ip6 dscp set cs2

        # down prioritize the first 500ms of tcp packets
        ip protocol tcp ct bytes < $first500ms ip dscp < cs4 ip dscp set cs2

        # downgrade tcp that has transferred more than 10 seconds worth of packets
        ip protocol tcp ct bytes > $first10s ip dscp < cs4 ip dscp set cs1

        ## tcp with less than 150 pps gets upgraded to cs4
        ip protocol tcp add @slowtcp4 {ip saddr . ip daddr . tcp sport . tcp dport limit rate 150/second burst 150 packets } ip dscp set cs4
        ip6 nexthdr tcp add @slowtcp6 {ip6 saddr . ip6 daddr . tcp sport . tcp dport limit rate 150/second burst 150 packets} ip6 dscp set cs4

        ## classify for the HFSC queues:
        meta priority set ip dscp map @priomap
        meta priority set ip6 dscp map @priomap

        meta oifname $wan ip dscp set cs0 ## comment out if you don't want to wash dscp upload to internet
        meta oifname $wan ip6 dscp set cs0 ## comment out like above
    }
}

then /etc/init.d/firewall restart
then connect to the game connexion service in line

then just "nft list ruleset" ## in ssh

the result is amazing

ip of my ps5 is 192.168.2.160

 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 limit rate over 450/second timeout 5m expires 3m44s140ms,
                             192.168.2.160 . 185.34.107.129 . 3074 . 3074 limit rate over 450/second timeout 5m expires 4m46s220ms,
                             185.34.107.128 . 192.168.2.160 . 3074 . 3074 limit rate over 450/second timeout 5m expires 4m40s980ms,
                             185.34.107.129 . 192.168.2.160 . 3074 . 3074 limit rate over 450/second timeout 5m expires 4m46s390ms,
                             173.199.105.74 . 192.168.2.160 . 40710 . 3074 limit rate over 450/second timeout 5m expires 3m46s310ms,
                             173.199.105.49 . 192.168.2.160 . 43110 . 3074 limit rate over 450/second timeout 5m expires 4m59s300ms,
                             149.28.185.155 . 192.168.2.160 . 44811 . 3076 limit rate over 450/second timeout 5m expires 4m55s610ms,
                             137.59.253.138 . 192.168.2.160 . 39181 . 3076 limit rate over 450/second timeout 5m expires 4m55s510ms,
                             107.182.231.179 . 192.168.2.160 . 39951 . 3076 limit rate over 450/second timeout 5m expires 4m54s930ms,
                             173.199.113.18 . 192.168.2.160 . 36371 . 3076 limit rate over 450/second timeout 5m expires 4m56s520ms,
                             92.223.85.18 . 192.168.2.160 . 35101 . 3076 limit rate over 450/second timeout 5m expires 4m55s210ms,
                             196.28.69.119 . 192.168.2.160 . 34101 . 3076 limit rate over 450/second timeout 5m expires 4m57s460ms,
                             148.72.169.142 . 192.168.2.160 . 36661 . 3076 limit rate over 450/second timeout 5m expires 4m56s710ms,
                             141.164.32.13 . 192.168.2.160 . 30521 . 3076 limit rate over 450/second timeout 5m expires 4m56s580ms,
                             204.74.232.54 . 192.168.2.160 . 40511 . 3076 limit rate over 450/second timeout 5m expires 4m53s400ms,
                             185.225.209.139 . 192.168.2.160 . 40021 . 3076 limit rate over 450/second timeout 5m expires 4m55s440ms,
                             108.61.232.231 . 192.168.2.160 . 31831 . 3076 limit rate over 450/second timeout 5m expires 4m56s900ms,
                             95.141.32.60 . 192.168.2.160 . 38231 . 3076 limit rate over 450/second timeout 5m expires 4m57s410ms,
                             173.199.105.100 . 192.168.2.160 . 34651 . 3076 limit rate over 450/second timeout 5m expires 4m55s830ms,
                             45.32.172.250 . 192.168.2.160 . 34401 . 3076 limit rate over 450/second timeout 5m expires 4m53s980ms,
                             173.244.208.125 . 192.168.2.160 . 42851 . 3076 limit rate over 450/second timeout 5m expires 4m53s720ms,
                             98.142.209.204 . 192.168.2.160 . 37221 . 3076 limit rate over 450/second timeout 5m expires 4m54s170ms,
                             88.150.240.180 . 192.168.2.160 . 37481 . 3076 limit rate over 450/second timeout 5m expires 4m55s550ms,
                             138.199.44.240 . 192.168.2.160 . 41071 . 3076 limit rate over 450/second timeout 5m expires 4m54s570ms,
                             37.244.43.207 . 192.168.2.160 . 33651 . 3076 limit rate over 450/second timeout 5m expires 4m56s310ms,
                             66.203.113.16 . 192.168.2.160 . 35961 . 3076 limit rate over 450/second timeout 5m expires 4m53s980ms,
                             95.179.204.47 . 192.168.2.160 . 33921 . 3076 limit rate over 450/second timeout 5m expires 4m54s280ms,
                             92.204.186.205 . 192.168.2.160 . 32131 . 3076 limit rate over 450/second timeout 5m expires 4m54s480ms,
                             103.14.27.180 . 192.168.2.160 . 37001 . 3076 limit rate over 450/second timeout 5m expires 4m57s110ms,
                             108.61.41.58 . 192.168.2.160 . 30091 . 3076 limit rate over 450/second timeout 5m expires 4m54s740ms,
                             45.63.80.249 . 192.168.2.160 . 31891 . 3076 limit rate over 450/second timeout 5m expires 4m56s270ms,
                             197.84.209.9 . 192.168.2.160 . 33941 . 3076 limit rate over 450/second timeout 5m expires 4m57s640ms,
                             69.88.157.153 . 192.168.2.160 . 32671 . 3076 limit rate over 450/second timeout 5m expires 4m56s360ms,
                             142.54.238.29 . 192.168.2.160 . 37031 . 3076 limit rate over 450/second timeout 5m expires 4m57s250ms,
                             45.63.112.10 . 192.168.2.160 . 30891 . 3076 limit rate over 450/second timeout 5m expires 4m57s200ms,
                             43.251.183.102 . 192.168.2.160 . 43441 . 3076 limit rate over 450/second timeout 5m expires 4m53s620ms,
                             177.54.152.156 . 192.168.2.160 . 31931 . 3076 limit rate over 450/second timeout 5m expires 4m54s960ms,
                             149.248.40.213 . 192.168.2.160 . 41921 . 3076 limit rate over 450/second timeout 5m expires 4m54s130ms,
                             192.252.212.110 . 192.168.2.160 . 33221 . 3076 limit rate over 450/second timeout 5m expires 4m53s650ms,
                             139.180.151.246 . 192.168.2.160 . 31431 . 3076 limit rate over 450/second timeout 5m expires 4m53s920ms,
                             165.73.240.214 . 192.168.2.160 . 39381 . 3076 limit rate over 450/second timeout 5m expires 4m55s900ms,
                             107.6.136.86 . 192.168.2.160 . 33751 . 3076 limit rate over 450/second timeout 5m expires 4m56s420ms,
                             96.30.201.61 . 192.168.2.160 . 34521 . 3076 limit rate over 450/second timeout 5m expires 4m55s720ms,
                             45.63.72.217 . 192.168.2.160 . 38111 . 3076 limit rate over 450/second timeout 5m expires 4m55s140ms,
                             199.116.113.69 . 192.168.2.160 . 32231 . 3076 limit rate over 450/second timeout 5m expires 4m55s240ms,
                             172.83.41.230 . 192.168.2.160 . 32501 . 3076 limit rate over 450/second timeout 5m expires 4m56s810ms,
                             45.76.73.97 . 192.168.2.160 . 44791 . 3076 limit rate over 450/second timeout 5m expires 4m57s140ms,
                             45.76.109.39 . 192.168.2.160 . 33021 . 3076 limit rate over 450/second timeout 5m expires 4m56s170ms,
                             108.61.97.16 . 192.168.2.160 . 40701 . 3076 limit rate over 450/second timeout 5m expires 4m54s190ms,
                             66.242.14.98 . 192.168.2.160 . 33791 . 3076 limit rate over 450/second timeout 5m expires 4m54s440ms,
                             192.168.2.160 . 173.199.105.74 . 3074 . 40710 limit rate over 450/second timeout 5m expires 3m46s290ms,
                             192.168.2.160 . 149.28.185.155 . 3076 . 44811 limit rate over 450/second timeout 5m expires 4m55s320ms,
                             192.168.2.160 . 137.59.253.138 . 3076 . 39181 limit rate over 450/second timeout 5m expires 4m55s230ms,
                             192.168.2.160 . 107.182.231.179 . 3076 . 39951 limit rate over 450/second timeout 5m expires 4m54s830ms,
                             192.168.2.160 . 173.199.113.18 . 3076 . 36371 limit rate over 450/second timeout 5m expires 4m56s500ms,
                             192.168.2.160 . 92.223.85.18 . 3076 . 35101 limit rate over 450/second timeout 5m expires 4m54s930ms,
                             192.168.2.160 . 196.28.69.119 . 3076 . 34101 limit rate over 450/second timeout 5m expires 4m57s280ms,
                             192.168.2.160 . 148.72.169.142 . 3076 . 36661 limit rate over 450/second timeout 5m expires 4m56s590ms,
                             192.168.2.160 . 141.164.32.13 . 3076 . 30521 limit rate over 450/second timeout 5m expires 4m56s300ms,
                             192.168.2.160 . 204.74.232.54 . 3076 . 40511 limit rate over 450/second timeout 5m expires 4m53s270ms,
                             192.168.2.160 . 185.225.209.139 . 3076 . 40021 limit rate over 450/second timeout 5m expires 4m55s420ms,
                             192.168.2.160 . 108.61.232.231 . 3076 . 31831 limit rate over 450/second timeout 5m expires 4m56s790ms,
                             192.168.2.160 . 95.141.32.60 . 3076 . 38231 limit rate over 450/second timeout 5m expires 4m57s370ms,
                             192.168.2.160 . 173.199.105.100 . 3076 . 34651 limit rate over 450/second timeout 5m expires 4m55s810ms,
                             192.168.2.160 . 45.32.172.250 . 3076 . 34401 limit rate over 450/second timeout 5m expires 4m53s860ms,
                             192.168.2.160 . 173.244.208.125 . 3076 . 42851 limit rate over 450/second timeout 5m expires 4m53s570ms,
                             192.168.2.160 . 98.142.209.204 . 3076 . 37221 limit rate over 450/second timeout 5m expires 4m54s50ms,
                             192.168.2.160 . 173.199.105.49 . 3074 . 43110 limit rate over 450/second timeout 5m expires 4m59s280ms,
                             192.168.2.160 . 88.150.240.180 . 3076 . 37481 limit rate over 450/second timeout 5m expires 4m55s520ms,
                             192.168.2.160 . 138.199.44.240 . 3076 . 41071 limit rate over 450/second timeout 5m expires 4m54s540ms,
                             192.168.2.160 . 37.244.43.207 . 3076 . 33651 limit rate over 450/second timeout 5m expires 4m56s10ms,
                             192.168.2.160 . 66.203.113.16 . 3076 . 35961 limit rate over 450/second timeout 5m expires 4m53s760ms,
                             192.168.2.160 . 95.179.204.47 . 3076 . 33921 limit rate over 450/second timeout 5m expires 4m54s250ms,
                             192.168.2.160 . 92.204.186.205 . 3076 . 32131 limit rate over 450/second timeout 5m expires 4m54s440ms,
                             192.168.2.160 . 103.14.27.180 . 3076 . 37001 limit rate over 450/second timeout 5m expires 4m56s890ms,
                             192.168.2.160 . 108.61.41.58 . 3076 . 30091 limit rate over 450/second timeout 5m expires 4m54s640ms,
                             192.168.2.160 . 45.63.80.249 . 3076 . 31891 limit rate over 450/second timeout 5m expires 4m56s100ms,
                             192.168.2.160 . 197.84.209.9 . 3076 . 33941 limit rate over 450/second timeout 5m expires 4m57s470ms,
                             192.168.2.160 . 69.88.157.153 . 3076 . 32671 limit rate over 450/second timeout 5m expires 4m56s200ms,
                             192.168.2.160 . 142.54.238.29 . 3076 . 37031 limit rate over 450/second timeout 5m expires 4m57s80ms,
                             192.168.2.160 . 45.63.112.10 . 3076 . 30891 limit rate over 450/second timeout 5m expires 4m57s180ms,
                             192.168.2.160 . 43.251.183.102 . 3076 . 43441 limit rate over 450/second timeout 5m expires 4m53s370ms,
                             192.168.2.160 . 177.54.152.156 . 3076 . 31931 limit rate over 450/second timeout 5m expires 4m54s740ms,
                             192.168.2.160 . 149.248.40.213 . 3076 . 41921 limit rate over 450/second timeout 5m expires 4m53s960ms,
                             192.168.2.160 . 192.252.212.110 . 3076 . 33221 limit rate over 450/second timeout 5m expires 4m53s470ms,
                             192.168.2.160 . 139.180.151.246 . 3076 . 31431 limit rate over 450/second timeout 5m expires 4m53s660ms,
                             192.168.2.160 . 165.73.240.214 . 3076 . 39381 limit rate over 450/second timeout 5m expires 4m55s710ms,
                             192.168.2.160 . 107.6.136.86 . 3076 . 33751 limit rate over 450/second timeout 5m expires 4m56s400ms,
                             192.168.2.160 . 96.30.201.61 . 3076 . 34521 limit rate over 450/second timeout 5m expires 4m55s620ms,
                             192.168.2.160 . 45.63.72.217 . 3076 . 38111 limit rate over 450/second timeout 5m expires 4m55s30ms,
                             192.168.2.160 . 199.116.113.69 . 3076 . 32231 limit rate over 450/second timeout 5m expires 4m55s130ms,
                             192.168.2.160 . 172.83.41.230 . 3076 . 32501 limit rate over 450/second timeout 5m expires 4m56s690ms,
                             192.168.2.160 . 45.76.73.97 . 3076 . 44791 limit rate over 450/second timeout 5m expires 4m56s980ms,
                             192.168.2.160 . 45.76.109.39 . 3076 . 33021 limit rate over 450/second timeout 5m expires 4m55s910ms,
                             192.168.2.160 . 108.61.97.16 . 3076 . 40701 limit rate over 450/second timeout 5m expires 4m54s150ms,
                             192.168.2.160 . 66.242.14.98 . 3076 . 33791 limit rate over 450/second timeout 5m expires 4m54s350ms }

@di_Niko @edwpat @joman maybe can interested if you play cod :wink:
thanks for your help by advance

1 Like

Salut, quel script est meilleur pour la fibre, parce que c’est catastrophique pour moi (j’ai vu que t’était un français 10 apres)

1 Like

yes i'm french user of openrwrt while a long time 10 years soon

send me a message for non pollute my topics it's ok ?

i responde more later because i'm a work actually thanks joman