Created
April 16, 2013 09:42
-
-
Save kntyskw/5394696 to your computer and use it in GitHub Desktop.
Add a routing table and iptables rule to route specified packets via LVS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LVS_IP=172.31.24.1 | |
TABLE=1 | |
ip route flush table $TABLE | |
ip route show | grep -Ev ^default | while read ROUTE; do | |
ip route add table $TABLE $ROUTE | |
done | |
ip route add table $TABLE default via $LVS_IP | |
ip rule del from all fwmark 1 | |
ip rule add fwmark 1 lookup $TABLE | |
iptables -F -t mangle | |
iptables -A OUTPUT -t mangle -p tcp --sport 80 -j MARK --set-mark 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment