Advertisement
Guest User

Untitled

a guest
Nov 27th, 2011
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. Wan Networks
  2. eth0 192.168.1.10/24 gateway 192.168.1.1
  3. eth1 192.168.2.10/24 gateway 192.168.2.1
  4. eth2 192.168.3.10/24 gateway 192.168.3.1
  5.  
  6. Lan Network
  7. eth3
  8.  
  9. edit /etc/iproute/rt_tables
  10. 201 table1
  11. 202 table2
  12. 203 table3
  13.  
  14. edit /etc/network/interfaces
  15.  
  16. auto eth0
  17. iface eth0 inet static
  18. address 192.168.1.10
  19. netmask 255.255.255.0
  20. # gateway 192.168.1.1
  21. broadcast 192.168.1.255
  22. network 192.168.1.0
  23.  
  24. post-up ip route add 192.168.1.0/24 dev eth0 src 192.168.1.10 table table1
  25. post-up ip route add default via 192.168.1.1 table table1
  26. post-up ip rule add from 192.168.1.10 table table1
  27. post-down ip rule del from 192.168.1.10 table table1
  28.  
  29. auto eth1
  30. iface eth1 inet static
  31. address 192.168.2.10
  32. netmask 255.255.255.0
  33. # gateway 192.168.2.1
  34. broadcast 192.168.2.255
  35. network 192.168.2.0
  36.  
  37. post-up ip route add 192.168.2.0/24 dev eth1 src 192.168.2.10 table table2
  38. post-up ip route add default via 192.168.2.1 table table2
  39. post-up ip rule add from 192.168.2.10 table table2
  40. post-down ip rule del from 192.168.2.10 table table2
  41.  
  42. auto eth2
  43. iface eth2 inet static
  44. address 192.168.3.10
  45. netmask 255.255.255.0
  46. # gateway 192.168.3.1
  47. broadcast 192.168.3.255
  48. network 192.168.3.0
  49.  
  50. post-up ip route add 192.168.3.0/24 dev eth2 src 192.168.3.10 table table3
  51. post-up ip route add default via 192.168.3.1 table table3
  52. post-up ip rule add from 192.168.3.10 table table3
  53. post-down ip rule del from 192.168.3.10 table table3
  54.  
  55. IPTABLES COMMAND
  56. iptables -t mangle -A PREROUTING -j CONNMARK --restore-mark
  57. iptables -t mangle -A PREROUTING -m mark ! --mark 0 -j ACCEPT
  58. iptables -t mangle -A PREROUTING -j MARK --set-mark 10
  59. iptables -t mangle -A PREROUTING -m statistic --mode random --probability 0.5 -j MARK --set-mark 20
  60. iptables -t mangle -A PREROUTING -j CONNMARK --save-mark
  61.  
  62. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  63. iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
  64. iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
  65.  
  66. edit /etc/rc.local
  67. ip route add default scope global nexthop via 192.168.1.1 dev eth0 weight 1 nexthop via 192.168.2.1 dev eth1 weight 1 nexthop via 192.168.3.1 dev eth2 weight 1
  68.  
  69. edit /proc/sys/net/ipv4/ip_forward
  70. 1
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement