alors :
table ip nat {
chain PREROUTING {
type nat hook prerouting priority dstnat; policy accept;
iifname "lan" ip daddr 192.168.42.253 tcp dport 53 counter packets 0 bytes 0 dnat to 192.168.42.253:54 comment "PREROUTE_kids_dns_tcp"
iifname "lan" ip daddr 192.168.42.253 udp dport 53 counter packets 0 bytes 0 dnat to 192.168.42.253:54 comment "PREROUTE_kids_dns_udp"
iifname "lan" ip saddr { 192.168.42.26, 192.168.42.27, 192.168.42.29, 192.168.42.30, 192.168.42.31, 192.168.42.36 } tcp dport 53 counter packets 0 bytes 0 dnat to 192.168.42.251:53 comment "PREROUTE_cast_dns_tcp"
iifname "lan" ip saddr { 192.168.42.26, 192.168.42.27, 192.168.42.29, 192.168.42.30, 192.168.42.31, 192.168.42.36 } udp dport 53 counter packets 1 bytes 60 dnat to 192.168.42.251:53 comment "PREROUTE_cast_dns_udp"
iifname { "wan1", "wan3", "orange2" } ip saddr != 192.168.0.0/16 tcp dport { 53, 1194 } counter packets 0 bytes 0 dnat to 192.168.42.254:1194 comment "PREROUTE_vpn_endpoint_tcp"
iifname { "wan1", "wan3", "orange2" } ip saddr != 192.168.0.0/16 udp dport { 53, 1194 } counter packets 0 bytes 0 dnat to 192.168.42.254:1194 comment "PREROUTE_vpn_endpoint_udp"
iifname { "tun3" } tcp dport { 10542, 20542, 30542 } counter packets 0 bytes 0 dnat to 192.168.42.53 comment "PREROUTE_vanisher_forward_tcp"
iifname { "tun3" } udp dport { 10542, 20542, 30542 } counter packets 0 bytes 0 dnat to 192.168.42.53 comment "PREROUTE_vanisher_forward_udp"
iifname { "wan1", "wan3", "orange2" } ip saddr != 192.168.0.0/16 tcp dport { 22, 80, 443 } counter packets 1 bytes 60 dnat to 192.168.42.51 comment "PREROUTE_wan_forward_tcp"
}
chain POSTROUTING {
type nat hook postrouting priority srcnat; policy accept;
ip daddr 80.10.247.48 udp dport 67 counter packets 0 bytes 0 meta mark set 0x00000200
oifname "wan1" ip saddr 192.168.0.0/16 counter packets 19 bytes 1540 masquerade comment "NAT_via_WAN1"
oifname "orange2" ip saddr 192.168.0.0/16 counter packets 1 bytes 84 masquerade comment "NAT_via_WAN2"
oifname { "tun0", "tun1", "tun2", "beta0" } ip saddr 192.168.0.0/16 counter packets 5 bytes 1877 masquerade comment "NAT_via_VPN"
oifname "beta0" ip saddr 192.168.0.0/16 counter packets 0 bytes 0 masquerade comment "NAT_via_BETA"
oifname { "tun3", "tun4", "tun5" } ip saddr 192.168.0.0/16 counter packets 1 bytes 108 masquerade comment "NAT_via_VANISHER"
}
}
table ip mangle {
chain PREROUTING {
type filter hook prerouting priority mangle; policy accept;
iifname "wan1" ct state new counter packets 1 bytes 44 jump MWAN1 comment "mwan1_orange1"
iifname "orange2" ct state new counter packets 3 bytes 180 jump MWAN2 comment "mwan1_orange2"
iifname "wan3" ct state new counter packets 25 bytes 1220 jump MWAN3 comment "mwan3_lte"
iifname "beta0" ct state new counter packets 0 bytes 0 jump MWAN5 comment "mwan5_beta"
iifname { "tun4" } ct state new counter packets 0 bytes 0 jump MWAN6 comment "mwan1_vanisher_orange1"
iifname { "tun5" } ct state new counter packets 0 bytes 0 jump MWAN7 comment "mwan1_vanisher_orange2"
iifname { "tun3" } ct state new counter packets 0 bytes 0 jump MWAN9 comment "mwan9_vanisher_lte"
ct state new counter packets 61 bytes 6578 jump MWAN
ct mark != 0x00000000 meta mark set ct mark
}
chain INPUT {
type filter hook input priority mangle; policy accept;
}
chain FORWARD {
type filter hook forward priority mangle; policy accept;
}
chain OUTPUT {
type route hook output priority mangle; policy accept;
ip daddr 80.10.247.48 udp dport 67 counter packets 0 bytes 0 jump MWANSL2 comment "mwan2_dhcp_orange2"
oifname "wan1" ct state new counter packets 19 bytes 1532 jump MWAN1 comment "mwan1_orange1"
oifname "orange2" ct state new counter packets 8 bytes 636 jump MWAN2 comment "mwan2_orange2"
oifname "wan3" ct state new counter packets 1 bytes 114 jump MWAN3 comment "mwan3_lte"
oifname "beta0" ct state new counter packets 0 bytes 0 jump MWAN5 comment "mwan5_beta"
oifname { "tun4" } ct state new counter packets 5 bytes 406 jump MWAN6 comment "mwan6_vanisher_orange1"
oifname { "tun5" } ct state new counter packets 0 bytes 0 jump MWAN7 comment "mwan7_vanisher_orange2"
oifname { "tun3" } ct state new counter packets 0 bytes 0 jump MWAN9 comment "mwan1_vanisher_lte"
ct state new counter packets 244 bytes 39811 jump MWAN
ct mark != 0x00000000 meta mark set ct mark
}
...
chain MWANSL1 {
meta mark set 0x00000100
counter packets 0 bytes 0 log prefix "netfilter_MWANSL1" group 0
}
chain MWANSL2 {
meta mark set 0x00000200
counter packets 0 bytes 0 log prefix "netfilter_MWANSL2" group 0
}
}
}
# ip rule add from all fwmark 0x200 lookup 200 pri 1
[20:31:47]root@cerber:/etc/nft.d # ip rule show
0: from all lookup local
1: from all fwmark 0x200 lookup 200
100: from 192.168.3.254 lookup 100
101: from all fwmark 0x100 lookup 100
200: from <moniporange> ookup 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.1.228.244 lookup 600
601: from all fwmark 0x600 lookup 600
700: from 10.2.19.249 lookup 700
701: from all fwmark 0x700 lookup 700
900: from 10.4.65.19 lookup 900
901: from all fwmark 0x900 lookup 900
32766: from all lookup main
32767: from all lookup default
# ip route show table 200
default via 82.127.187.1 dev orange2
10.1.228.0/24 dev tun4 scope link src 10.1.228.244
10.2.19.0/24 dev tun5 scope link src 10.2.19.249
10.4.65.0/24 dev tun3 scope link src 10.4.65.19
82.127.187.0/25 dev orange2 proto kernel scope link src <moniporange>
192.168.2.0/24 dev wan2 proto kernel scope link src 192.168.2.254
192.168.3.0/24 dev wan1 proto kernel scope link src 192.168.3.254
192.168.4.0/24 dev wan3 proto kernel scope link src 192.168.4.254
192.168.42.0/24 dev lan proto kernel scope link src 192.168.42.254
192.168.43.0/24 dev tun0 proto kernel scope link src 192.168.43.1
192.168.46.0/24 dev tun2 proto kernel scope link src 192.168.46.2
192.168.48.0/24 dev tun1 proto kernel scope link src 192.168.48.1
192.168.251.0/30 dev beta0 scope link src 192.168.251.2
logs netfilter :
Sep 29 20:34:47 cerber netfilter_MWANSL2 IN= OUT=wan1 MAC= SRC=192.168.3.254 DST=80.10.247.48 LEN=411 TOS=00 PREC=0x00 TTL=64 ID=8844 PROTO=UDP SPT=68 DPT=67 LEN=391 UID=0 GID=0 MARK=200