xref: /linux-tools/misc/scripts/iptables/iptables-lb.tips (revision de922be4e919572d28577568db563e691d5e7702)
1root@worker1:/home/linan/demo1# iptables -t nat -N myservice
2root@worker1:/home/linan/demo1# iptables -t nat -A OUTPUT -d 10.10.0.0/16 -j myservice
3root@worker1:/home/linan/demo1# iptables -t nat -A myservice -d 10.10.0.1 -m statistic --mode random --probability 0.3333 -j DNAT --to-destination 172.18.1.3
4root@worker1:/home/linan/demo1# iptables -t nat -A myservice -d 10.10.0.1 -m statistic --mode random --probability 0.5 -j DNAT --to-destination 172.18.1.4
5root@worker1:/home/linan/demo1# iptables -t nat -A myservice -d 10.10.0.1  -j DNAT --to-destination 172.18.1.5
6
7# -m statistic --mode nth --every 3 --packet 0
8iptables -t nat -A POSTROUTING -s 172.18.1.5 -d 172.18.1.5 -j MASQUERADE
9