Premièrement la route dans la table main avec nexthop ne fonctionne pas, c'est soit l'un soit l'autre.
Suite aux modifs proposées par Xavier, j'ai effectivement 3 logs par DHCPREQUEST. Actuellement, c'est mon orange2 qui ne parvient pas à faire son RENEW. Pourtant, dans les logs, cela provient de l'IP orange1, alors que c'est le dhclient de l'interface orange2...
Oct 03 08:31:10 cerber.nbux.org kernel: mangle/OUTPUT: entering IN= OUT=orange1 SRC=<iporange1> DST=80.10.247.48 LEN=411 TOS=0x00 PREC=0x00 TTL=64 ID=34374 PROTO=UDP SPT=68 DPT=67 LEN=391
Oct 03 08:31:10 cerber.nbux.org kernel: mangle/OUTPUT: about to mark IN= OUT=orange1 SRC=<iporange1> DST=80.10.247.48 LEN=411 TOS=0x00 PREC=0x00 TTL=64 ID=34374 PROTO=UDP SPT=68 DPT=67 LEN=391 MARK=0x100
Oct 03 08:31:10 cerber.nbux.org kernel: mangle/OUTPUT: freshly marked IN= OUT=orange1 SRC=<iporange1> DST=80.10.247.48 LEN=411 TOS=0x00 PREC=0x00 TTL=64 ID=34374 PROTO=UDP SPT=68 DPT=67 LEN=391 MARK=0xcafecafe
Oct 03 08:31:27 cerber.nbux.org kernel: mangle/OUTPUT: entering IN= OUT=orange1 SRC=<iporange1> DST=80.10.247.48 LEN=411 TOS=0x00 PREC=0x00 TTL=64 ID=35298 PROTO=UDP SPT=68 DPT=67 LEN=391
Oct 03 08:31:27 cerber.nbux.org kernel: mangle/OUTPUT: about to mark IN= OUT=orange1 SRC=<iporange1> DST=80.10.247.48 LEN=411 TOS=0x00 PREC=0x00 TTL=64 ID=35298 PROTO=UDP SPT=68 DPT=67 LEN=391 MARK=0x100
Oct 03 08:31:27 cerber.nbux.org kernel: mangle/OUTPUT: freshly marked IN= OUT=orange1 SRC=<iporange1> DST=80.10.247.48 LEN=411 TOS=0x00 PREC=0x00 TTL=64 ID=35298 PROTO=UDP SPT=68 DPT=67 LEN=391 MARK=0xcafecafe
Compte-tenu de mes ip rules, c'est logique je crois ?
0: from all lookup local
100: from <iporange1> lookup 100
101: from all fwmark 0x100 lookup 100
200: from <iporange2> lookup 200
201: from all fwmark 0x200 lookup 200
300: from 192.168.4.254 lookup 300
301: from all fwmark 0x300 lookup 300
500: from 192.168.251.2 lookup 500
501: from all fwmark 0x500 lookup 500
600: from 10.4.113.251 lookup 600
601: from all fwmark 0x600 lookup 600
700: from 10.2.0.244 lookup 700
701: from all fwmark 0x700 lookup 700
900: from 10.0.49.26 lookup 900
901: from all fwmark 0x900 lookup 900
32766: from all lookup main
32767: from all lookup default
Ensuite, merci ZOC pour ta suggestion.
En réfléchissant (si si ça m'arrive
, je ne vois pas comment marker mes paquets dans ces conditions sachant que l'interface ET l'IP source ne sont pas bons. Du coup, effectivement, il reste de le process (ou le skgid comme l'avait suggéré Xavier avant d'ailleurs).
J'ai modifié ma table mangle/OUTPUT en ajoutant un markage sur meta cgroup.
chain OUTPUT {
type route hook output priority mangle; policy accept;
oifname $iface_wan1 ct state new counter jump MWAN1 comment "mwan1_orange1"
oifname $iface_wan2 ct state new counter jump MWAN2 comment "mwan2_orange2"
oifname $iface_wan3 ct state new counter jump MWAN3 comment "mwan3_lte"
oifname $iface_beta ct state new counter jump MWAN5 comment "mwan5_beta"
oifname $iface_vanisher1 ct state new counter jump MWAN6 comment "mwan6_vanisher_orange1"
oifname $iface_vanisher2 ct state new counter jump MWAN7 comment "mwan7_vanisher_orange2"
oifname $iface_vanisher3 ct state new counter jump MWAN9 comment "mwan1_vanisher_lte"
ct state new counter jump MWAN
ct mark != 0x0 meta mark set ct mark
# to force DHCP RENEW cgroup process via its own iface
udp sport 68 udp dport 67 meta cgroup $cgroup_wan1 counter jump MWAN1_CGROUP comment "mwan1_dhcpc_cgroup"
udp sport 68 udp dport 67 meta cgroup $cgroup_wan2 counter jump MWAN2_CGROUP comment "mwan2_dhcpc_cgroup"
}
chain MWAN1_CGROUP {
counter meta mark set 0x100
log prefix "netfilter_MWAN1_CGROUP" group 0
}
chain MWAN2_CGROUP {
counter meta mark set 0x200
log prefix "netfilter_MWAN2_CGROUP" group 0
}
chain MWAN3_CGROUP {
counter meta mark set 0x300
log prefix "netfilter_MWAN3_CGROUP" group 0
}
j'ai modifié mes rules :
0: from all lookup local
1: from all fwmark 0x100 ipproto udp sport 68 dport 67 lookup 100
2: from all fwmark 0x200 ipproto udp sport 68 dport 67 lookup 200
100: from <iporange1> lookup 100
101: from all fwmark 0x100 lookup 100
200: from <iporange2> lookup 200
201: from all fwmark 0x200 lookup 200
300: from 192.168.4.254 lookup 300
301: from all fwmark 0x300 lookup 300
500: from 192.168.251.2 lookup 500
501: from all fwmark 0x500 lookup 500
600: from 10.4.102.16 lookup 600
601: from all fwmark 0x600 lookup 600
700: from 10.2.23.241 lookup 700
701: from all fwmark 0x700 lookup 700
900: from 10.3.5.248 lookup 900
901: from all fwmark 0x900 lookup 900
32766: from all lookup main
32767: from all lookup default
ensuite, j'ai ajouté les PID des process dhclient dans /sys/fs/cgroup/net_cls/dhcp-orange1|2/tasks et chacun avec son $cgroup_wanX dans /sys/fs/cgroup/net_cls/dhcp-orange1|2/net_cls.classid
Résultat, ca a marché de suite, le RENEW de l'interface orange2 est passé direct !
Par contre, ne sachant pas trop, dois-je ajouter les lignes de markage cgroup dans la chain OUTPUT AVANT le "meta mark set ct mark" final ?
Est-ce une bonne idée, je ne sais pas ... qu'en pensez-vous ? d'un point de vue perf, c'est surement mieux non ?
Ca ressemblerait à cela :
chain OUTPUT {
type route hook output priority mangle; policy accept;
oifname $iface_wan1 ct state new counter jump MWAN1 comment "mwan1_orange1"
oifname $iface_wan2 ct state new counter jump MWAN2 comment "mwan2_orange2"
oifname $iface_wan3 ct state new counter jump MWAN3 comment "mwan3_lte"
oifname $iface_beta ct state new counter jump MWAN5 comment "mwan5_beta"
oifname $iface_vanisher1 ct state new counter jump MWAN6 comment "mwan6_vanisher_orange1"
oifname $iface_vanisher2 ct state new counter jump MWAN7 comment "mwan7_vanisher_orange2"
oifname $iface_vanisher3 ct state new counter jump MWAN9 comment "mwan1_vanisher_lte"
# to force DHCP RENEW cgroup process via its own iface
udp sport 68 udp dport 67 meta cgroup $cgroup_wan1 counter jump MWAN1_CGROUP comment "mwan1_dhcpc_cgroup"
udp sport 68 udp dport 67 meta cgroup $cgroup_wan2 counter jump MWAN2_CGROUP comment "mwan2_dhcpc_cgroup"
ct state new counter jump MWAN
ct mark != 0x0 meta mark set ct mark
}
Enfin, c'est vrai que ce serait plus simple sans utiliser les cgroup et d'arriver à marker les paquets avec une regle mangle/OUTPUT, mais compte-tenu des caractéristiques des paquets, avec l'ip source et l'interface qui correspondent bien (alors que c'est faux), j'avoue que je ne vois pas trop comment faire.
Ou alors le gid du process dhclient et une regle nftables du genre :
chain OUTPUT {
type route hook output priority mangle; policy accept;
oifname $iface_wan1 ct state new counter jump MWAN1 comment "mwan1_orange1"
oifname $iface_wan2 ct state new counter jump MWAN2 comment "mwan2_orange2"
oifname $iface_wan3 ct state new counter jump MWAN3 comment "mwan3_lte"
oifname $iface_beta ct state new counter jump MWAN5 comment "mwan5_beta"
oifname $iface_vanisher1 ct state new counter jump MWAN6 comment "mwan6_vanisher_orange1"
oifname $iface_vanisher2 ct state new counter jump MWAN7 comment "mwan7_vanisher_orange2"
oifname $iface_vanisher3 ct state new counter jump MWAN9 comment "mwan1_vanisher_lte"
# to force DHCP RENEW cgroup process via its own iface
udp sport 68 udp dport 67 meta skgid $skgid_wan1 counter jump MWAN1_CGROUP comment "mwan1_dhcpc_skgid"
udp sport 68 udp dport 67 meta skgid $skgid_wan2 counter jump MWAN2_CGROUP comment "mwan2_dhcpc_skgid"
ct state new counter jump MWAN
ct mark != 0x0 meta mark set ct mark
}
C'est peut-être plus simple et plus flexible, il suffirait de faire tourner les process dans leur groupe...
La question qui persiste, est de savoir s'il faut mettre les regles nft avant ou apres le 'meta mark set ct mark' final de la chain OUTPUT ?
Et dois-je marké les paquets dans les chains mangle/OUTPUT, mangle/PRETROUTING et mangle/POSTROUTING comme je le fais, ou bien mangle/OUTPUT et mangle/PREROUTING ne suffirait-il pas ?