# iptables -t nat -m statistic --mode nth --help
iptables v1.3.5: Couldn't load match `statistic':/lib64/iptables/libipt_statistic.so: cannot open shared object file: No such file or directory
ха, а в моём ols 6.1 есть. поищите в репах yum search patchomatic и yum search iptables — может можно доставить модули или пропатчить ядро, чтобы оно появилось
[root@vlad-laptop vladislav]# iptables -A OUTPUT -m statistic --mode nth --every 3 -d 8.8.4.4 -j REJECT
[root@vlad-laptop vladislav]# ping 8.8.4.4
PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data.
From 192.168.1.234 icmp_seq=1 Destination Port Unreachable
64 bytes from 8.8.4.4: icmp_seq=1 ttl=54 time=45.2 ms
64 bytes from 8.8.4.4: icmp_seq=2 ttl=54 time=45.1 ms
From 192.168.1.234 icmp_seq=3 Destination Port Unreachable
64 bytes from 8.8.4.4: icmp_seq=3 ttl=54 time=45.3 ms
64 bytes from 8.8.4.4: icmp_seq=4 ttl=54 time=45.1 ms
From 192.168.1.234 icmp_seq=5 Destination Port Unreachable
64 bytes from 8.8.4.4: icmp_seq=5 ttl=54 time=45.0 ms
64 bytes from 8.8.4.4: icmp_seq=6 ttl=54 time=45.4 ms
From 192.168.1.234 icmp_seq=7 Destination Port Unreachable
64 bytes from 8.8.4.4: icmp_seq=7 ttl=54 time=45.0 ms
64 bytes from 8.8.4.4: icmp_seq=8 ttl=54 time=44.8 ms
From 192.168.1.234 icmp_seq=9 Destination Port Unreachable
64 bytes from 8.8.4.4: icmp_seq=9 ttl=54 time=45.1 ms
64 bytes from 8.8.4.4: icmp_seq=10 ttl=54 time=45.0 ms
From 192.168.1.234 icmp_seq=11 Destination Port Unreachable
64 bytes from 8.8.4.4: icmp_seq=11 ttl=54 time=45.1 ms
^C
--- 8.8.4.4 ping statistics ---
11 packets transmitted, 11 received, +6 errors, 0% packet loss, time 10401ms
rtt min/avg/max/mdev = 44.843/45.142/45.432/0.199 ms
[root@vlad-laptop vladislav]#
# iptables -A PREROUTING -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 4 --packet 0 -j DNAT --to-destination 192.168.0.5:443
iptables v1.3.5: Couldn't load match `nth':/lib64/iptables/libipt_nth.so: cannot open shared object file: No such file or directory
если я правильно понял вашу идею, это не будет работать, оно будет пакеты внутри одного соединения раскидывать по разным машинам, а это недопустимо. у действия DNAT есть возможность балансировать по сессии на разные адреса. как альтернативу вы можете использовать программный балансер, типа nginx
DNAT
This target is only valid in the nat table, in the PREROUTING and OUT-
PUT chains, and user-defined chains which are only called from those
chains. It specifies that the destination address of the packet should
be modified (and all future packets in this connection will also be
mangled), and rules should cease being examined. It takes one type of
option:
--to-destination [ipaddr][-ipaddr][:port[-port]]
which can specify a single new destination IP address, an inclu-
sive range of IP addresses, and optionally, a port range (which
is only valid if the rule also specifies -p tcp or -p udp). If
no port range is specified, then the destination port will never
be modified. If no IP address is specified then only the desti-
nation port will be modified.
In Kernels up to 2.6.10 you can add several --to-destination
options. For those kernels, if you specify more than one desti-
nation address, either via an address range or multiple
--to-destination options, a simple round-robin (one after
another in cycle) load balancing takes place between these
addresses. Later Kernels (>= 2.6.11-rc1) don't have the ability
to NAT to multiple ranges anymore.