Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello. Sorry my ENGLISH.
I have a connection to 2 (two) ISP on SLES 11.The routing is working.
Script of my gateway below.
NET_LOCAL1 goes via first ISP, LOCAL_NET2 goes via second ISP. For example, NET_LOCAL1 has address from network 192.168.1.0/24.
But how can i do connnection to Internet from address 192.168.1.5 via second ISP (GW_PROV2)???
--------------------------------------------------------------------
I find 2 ways:
1) use fwmark:
iptables -t mangle -A PREROUTING -s 192.168.1.5 -j MARK --set-mark 10
iptables -t mangle -A PREROUTING -s 192.168.1.0/24 -j MARK --set-mark 20
iptables -t nat -A POSTROUTING -m mark --mark 10 -j SNAT --to-source $IP_PROV2
iptables -t nat -A POSTROUTING -m mark --mark 20 -j SNAT --to-source $IP_PROV1
ip rule add fwmark 10 lookup T_PROV2
ip rule add fwmark 20 lookup T_PROV1
2) use this command:
iptables -t nat -A POSTROUTING -s 192.168.1.5 -o $IF_PROV2 -j SNAT --to-source $IP_PROV2
ip rule add from 192.168.10.2 lookup T_PROV2 pref 2001
---------------------------------------------------------------------
#!/bin/bash
echo "1">/proc/sys/net/ipv4/ip_forward
iptables -t nat -F
iptables -t mangle -F
ip route flush table T_PROV1
ip route flush table T_PROV2
iptables -t nat -A POSTROUTING -s $NET_LOCAL1 -o $IF_PROV1 -j SNAT --to-source $IP_PROV1
#T_PROV1
ip route add $NET_LOCAL1 dev $IF_LOCAL1 src $IP_LOCAL1 table T_PROV1
ip route add $NET_PROV1 dev $IF_PROV1 src $IP_PROV1 table T_PROV1
ip route add $NET_LOCAL2 dev $IF_LOCAL2 src $IP_LOCAL2 table T_PROV1
ip route add $NET_PROV2 dev $IF_PROV2 src $IP_PROV2 table T_PROV1
ip route add default via $GW_PROV1 table T_PROV1
ip route add 127.0.0.0/8 dev lo table T_PROV1
#T_PROV2
ip route add $NET_PROV2 dev $IF_PROV2 src $IP_PROV2 table T_PROV2
ip route add $NET_PROV1 dev $IF_PROV1 src $IP_PROV1 table T_PROV2
ip route add $NET_LOCAL2 dev $IF_LOCAL2 src $IP_LOCAL2 table
ip route add $NET_LOCAL1 dev $IF_LOCAL1 src $IP_LOCAL1 table T_PROV2
ip route add default via $GW_PROV2 table T_PROV2
ip route add 127.0.0.0/8 dev lo table T_PROV2
#main
ip route add $NET_LOCAL1 dev $IF_LOCAL1 src $IP_LOCAL1
ip route add $NET_PROV1 dev $IF_PROV1 src $IP_PROV1
ip route add $NET_PROV2 dev $IF_PROV2 src $IP_PROV2
ip route add $NET_LOCAL2 dev $IF_LOCAL2 src $IP_LOCAL1
ip route add default via $GW_PROV2
ip rule delete table T_PROV1
ip rule delete table T_PROV1
ip rule delete table T_PROV2
ip rule delete table T_PROV2
ip rule delete table T_PROV1
ip rule delete table T_PROV1
ip rule delete table T_PROV2
ip rule delete table T_PROV2
ip rule add from $IP_PROV1 lookup T_PROV1 pref 2010
ip rule add from $IP_PROV2 lookup T_PROV2 pref 2020
ip rule add from $NET_LOCAL1 lookup T_PROV1 pref 2030
ip rule add from $NET_LOCAL2 lookup T_PROV2 pref 2040
ip route flush cache
exit 0.
----------------------------------------------------------
What way will be better for perfomance of Linux server?
Or there are some different type of solve task of regulate diff address go via diff ISP?
Please help.....
your missing a default gateway to route to both networks..
Why???
Code:
#T_PROV1
ip route add default via $GW_PROV1 table T_PROV1
#T_PROV2
ip route add default via $GW_PROV2 table T_PROV2
#main
ip route add default via $GW_PROV2
Quote:
Originally Posted by evilted
heres an example:
Code:
ip route default nexthop via $GW1 dev $EXTIF1 weight $W1 nexthop via $GW2 dev $EXTIF2 weight $W2
to make it a bit easier, relax your firewall until you get the load balancing working correctly then start messing with your rules.
I don't need load balancing, i want to change access to the Internet for PC from local network via different ISP.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.