Eu consultei vários tutoriais para obter balanceamento de carga em duas conexões de internet. No entanto, todo o tráfego continua sendo roteado pela rota padrão com a métrica mais baixa e não consigo entender por que
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
ip rule delete from all fwmark 0x1
ip rule delete from all fwmark 0x2
ip rule flush
ip rule add lookup main priority 32766
iptables -A PREROUTING -t mangle -j CONNMARK --restore-mark
iptables -A PREROUTING -t mangle -m mark --mark 0x0 -m statistic \
--mode nth --every 2 --packet 0 -j MARK --set-mark 1
iptables -A PREROUTING -t mangle -m mark --mark 0x0 -m statistic \
--mode nth --every 2 --packet 1 -j MARK --set-mark 2
iptables -A POSTROUTING -t mangle -j CONNMARK --save-mark
ip route flush table wlp3s0
ip route flush table enp0s20u2
ip route add default via 46.37.116.1 table wlp3s0
ip route add 46.37.116.0/23 dev wlp3s0 table wlp3s0
ip route add default via 192.168.42.129 table enp0s20u2
ip route add 192.168.42.0/24 dev enp0s20u2 table enp0s20u2
ip rule add fwmark 1 lookup wlp3s0 priority 1000
ip rule add fwmark 2 lookup enp0s20u2 priority 1000
iptables -A POSTROUTING -t nat -m mark --mark 1 -j SNAT --to-source 46.37.116.111
iptables -A POSTROUTING -t nat -m mark --mark 2 -j SNAT --to-source 192.168.42.130
echo 0 > "/proc/sys/net/ipv4/conf/wlp3s0/rp_filter"
echo 0 > "/proc/sys/net/ipv4/conf/enp0s20u2/rp_filter"
ip route flush cache
rota ip:
ip route
default via 192.168.42.129 dev enp0s20u2 src 192.168.42.130 metric 207
default via 46.37.116.1 dev wlp3s0 src 46.37.116.111 metric 303
46.37.116.0/23 dev wlp3s0 proto kernel scope link src 46.37.116.111 metric 303
192.168.42.0/24 dev enp0s20u2 proto kernel scope link src 192.168.42.130 metric 207
ip route list todos os quadros wlp3s0
default via 46.37.116.1 dev wlp3s0
46.37.116.0/23 dev wlp3s0 scope link
ip route list toda a tabela enp0s20u2
default via 192.168.42.129 dev enp0s20u2
192.168.42.0/24 dev enp0s20u2 scope link
regra ip
0: from all lookup local
1000: from all fwmark 0x1 lookup wlp3s0
1000: from all fwmark 0x2 lookup enp0s20u2
32766: from all lookup main