Advertisement
Guest User

multihome routing setup

a guest
Aug 19th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #setup the route table per wan
  2. ip route add 0/0 via <gw1> dev <wan1> table 11
  3. ip route add 0/0 via <gw2> dev <wan2> table 12
  4.  
  5. #reply from right local addresses
  6. ip rule add from <wan1_ip> table 11 pref 91
  7. ip rule add from <wan2_ip> table 12 pref 92
  8.  
  9. #route by mark
  10. ip rule add fwmark 11 table 11 pref 101
  11. ip rule add fwmark 12 table 12 pref 102
  12.  
  13. #setup the dnat
  14. iptables -t nat -A PREROUTING -i <wan1> --dst <wan1_ip> -p <proto> --dport <service-port> -j DNAT --to <int_server_ip>
  15. iptables -t nat -A PREROUTING -i <wan2> --dst <wan2_ip> -p <proto> --dport <service-port> -j DNAT --to <int_server_ip>
  16.  
  17. #mark the incoming connections with CONNMARK
  18. iptables -t mangle -A PREROUTING -i <wan1> -m conntrack --ctstatus DNAT --ctstatus NEW -j CONNMARK --set-mark 11
  19. iptables -t mangle -A PREROUTING -i <wan2> -m conntrack --ctstatus DNAT --ctstatus NEW -j CONNMARK --set-mark 12
  20.  
  21. #reflect the connmark to firewall mark in reply packets
  22. iptables -t mangle -A PREROUTING -i <lan> --src <int_server_ip> -j CONNMARK --restore-mark
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement