LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Mutiple Outbound Internet Connections (https://www.linuxquestions.org/questions/linux-networking-3/mutiple-outbound-internet-connections-4175413221/)

Cheerz 06-25-2012 03:12 AM

Mutiple Outbound Internet Connections
 
Hi All

I need some assistance in getting my Multi WAN (Outbound internet) connections set up. Followed various articles on the internet and my configuration is included.

My scenario is as follows:

LAN Connection
eth0 - 10.3.1.0/24

Internet Connections using 2 ADSL lines (I just hooked up to existing connections in order for me to do some testing)

eth1 - 192.168.1.2/24 - GW 192.168.1.1
eth2 - 192.168.2.2/24 - GW 192.168.2.1

routes:

ip route add 192.168.1.0/24 dev eth1 src 192.168.1.2 table 1
ip route add default via 192.168.1.1 table 1
ip rule add from 192.168.1.2 table 1

ip route add 192.168.2.0/24 dev eth2 src 192.168.2.2 table 2
ip route add default via 192.168.2.1 table 2
ip rule add from 192.168.2.2 table 2

ip route replace default scope global nexthop via 192.168.1.1 dev eth1 weight 1 nexthop via 192.168.2.1 dev eth2 weight 1


iptables:

iptables -t mangle -N WAN0
iptables -t mangle -N WAN1
iptables -t mangle -N RESTORE
iptables -t mangle -A RESTORE -j CONNMARK --restore-mark
iptables -t mangle -A WAN0 -j MARK --set-mark 1
iptables -t mangle -A WAN0 -j CONNMARK --save-mark
iptables -t mangle -A WAN1 -j MARK --set-mark 2
iptables -t mangle -A WAN1 -j CONNMARK --save-mark
iptables -t mangle -A PREROUTING -i eth0 -p tcp -m state --state ESTABLISHED,RELATED -j RESTORE
iptables -t mangle -A PREROUTING -p tcp -m state --state NEW -m statistic --mode nth --every 2 --packet 0 -j WAN0
iptables -t mangle -A PREROUTING -p tcp -m state --state NEW -m statistic --mode nth --every 2 --packet 1 -j WAN1
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

When doing traceroutes the traffic is leaving one of the two WAN links. Normal browsing works fine but downloads are extremely slow or time out after a while. Using the ADSL's normally from a system works fine.

nini09 06-25-2012 02:43 PM

Routing specific subnet (source ip) to a particular interface should be like this.
"ip rule add from 1.2.3.4/24 table 1"
"ip route add 1.2.3.4/24 table 1 dev eth4"
All traffic from 1.2.3.4/24 will be routed using routing table 1 through eth4.


All times are GMT -5. The time now is 01:45 PM.