Skip to content

Instantly share code, notes, and snippets.

@sandromello
Created July 13, 2014 23:47
Show Gist options
  • Save sandromello/36b35945c2413bcab7c7 to your computer and use it in GitHub Desktop.
Save sandromello/36b35945c2413bcab7c7 to your computer and use it in GitHub Desktop.
Round Robin iptables
#!/bin/bash
#FLUSH
iptables -F
iptables -t nat -F
iptables -F REGRAS_SNAT
iptables -X REGRAS_SNAT
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I POSTROUTING -s 172.22.9.0/24 -o eth1 -j MASQUERADE
iptables -t nat -N REGRAS_SNAT
iptables -t nat -I POSTROUTING -j REGRAS_SNAT
iptables -t nat -A REGRAS_SNAT -d 172.22.9.0/24 -j RETURN
iptables -t nat -A REGRAS_SNAT -o eth1 -s 200.20.228.6/32 -p tcp --dport 25 -j SNAT --to 200.20.228.11-200.20.228.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment