Answer the question
In order to leave comments, you need to log in
How to split traffic on linux?
There are two providers on the device, one is cheap and slow and the other is expensive but fast. As an example: I want only mail to work through a cheap one, and YouTube and other traffic go through the road.
How to configure routing and firewall (iptables)?
Answer the question
In order to leave comments, you need to log in
It is necessary to configure complex routing.
Let the "cheap and slow provider" give you the IP address "IP1"
and the "expensive but fast provider" give you the IP address "IP2"
. Those. "mail" (SendMail or whoever you have) should open a connection from IP1, and users' browsers worked from IP2. Depends on it - through what provider you will be sent the answer.
The mail program must have an option in the config - from which address to open the connection.
Or you can drive TCP:25 traffic into NAT in iptables to convert the IP address.
And user programs are probably already configured to work through NAT (more precisely, the server intercepts their traffic and NATit. It is enough to correctly register the IP address IP2. Moreover, it is possible that SMTP and POP3 work for users - then you need to change the NAT rules by entering ports 25 there, 110 and what else is used there - on IP1
.
1. Option 1:
route add default gw expensive_provider_gateway (or via connection_interface)
route add ip_mail_address gw cheap provider_gateway (or via connection_interface).
2. Option 2:
Torment with BGP
Use iproute2. It allows you to route marked traffic, for example, in iptables.
Mark the traffic you need and tell ip route where to route it.
A simpler option is if you use NAT, then you can use -j SNAT --to-source your output ip
instead of -j MASQUERADE
Accordingly, it will be different for different types of traffic.
One friend did something similar on FreeBSD, ipfw, he also made it so that when one provider is turned off, all traffic turns to another, you can dig in this direction.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question