имеется 3 аплинка, не ходит трафик по не дефолтному маршруту.
схема для наглядности https://ibb.co/GWWmwCj
ядро Linux 5.10.52-gentoo
ip ro, ip rule, ipset
# ip route show table utel1
default via 172.21.3.1 dev vlan0302 metric 10
172.21.3.0/24 dev vlan0302 scope link metric 10
# ip route show table utel2
default via 172.21.4.1 dev vlan0303 metric 16
172.21.4.0/24 dev vlan0303 scope link metric 16
# ip rule
0: from all lookup local
20999: from 172.21.4.0/24 lookup utel2
21000: from all fwmark 0x3 lookup starnet
21999: from x.x.x.0/24 lookup ***rnet
22000: from all fwmark 0x1 lookup utel1
22000: from all fwmark 0x2 lookup utel2
32765: from 172.21.3.0/24 lookup utel1
32766: from all lookup main
32767: from all lookup default
# ipset list utel1
Name: utel1
Type: hash:net
Revision: 6
Header: family inet hashsize 1024 maxelem 65536
Size in memory: 512
References: 2
Number of entries: 1
Members:
192.168.140.2
iptables
#!/bin/bash
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t mangle -N UTEL1
iptables -t mangle -A UTEL1 -j MARK --set-mark 1
iptables -t mangle -A UTEL1 -j CONNMARK --save-mark
iptables -t mangle -N UTEL2
iptables -t mangle -A UTEL2 -j MARK --set-mark 2
iptables -t mangle -A UTEL2 -j CONNMARK --save-mark
iptables -t mangle -A PREROUTING -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
iptables -t mangle -A PREROUTING -m state --state NEW -m set --match-set utel1 src -j UTEL1
iptables -t mangle -A PREROUTING -m state --state NEW -m set --match-set utel2 src -j UTEL2
iptables -t nat -N SNATUTEL1
iptables -t nat -A SNATUTEL1 -j SNAT --to-source 172.21.3.2
iptables -t nat -N SNATUTEL2
iptables -t nat -A SNATUTEL2 -j SNAT --to-source 172.21.4.2
iptables -t nat -A POSTROUTING -m set --match-set utel1 src -j SNATUTEL1
iptables -t nat -A POSTROUTING -m set --match-set utel2 src -j SNATUTEL2
вот что происходит после nat’a (скрин) https://ibb.co/mDWWKCP
ping 1.1.1.1 c 192.168.140.2
туда: 192.168.140.2 – 192.168.140.1 – 172.21.3.2 — 172.21.3.1 – в мир
обратно: мир - 172.21.3.1(dst 192.168.140.2 (откуда? 172.21.3.1 о подсети 192.168.140.0 ничего не знает соответственно пакет отбрасывает))
любая помощь будет полезна.