Re: Recognizing traffic from multiple gateways

janjan-1ZQ7qlsa+hqxcEK7XZD/[email protected] Tue, 12 Jul 2016 10:33:38 -0400 (EDT)
Newsgroups gmane.org.user-groups.linux.philippine
Message-ID <[email protected]>
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---120695892-1567336435-1468334018=:17234
Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable


Hi Mike,

Try zen loadbalancer, your setup is quite close of this one:

https://www.zenloadbalancer.com/quick-start-guide-for-uplinks-load-balanc=
ing-with-zen-load-balancer/

you can set up a vip and route it to your reals, see if that helps.

Thanks.

Regards,

Janjan

On Mon, 4 Jul 2016, Michael Tinsay wrote:

> Hi fooler,
>=20
>=20
> I understand multiple routing tables for multi-NIC setup. =C2=A0However=
, My setup is more like both routers and my server is connected to a netw=
ork switch, to put it simply. =C2=A0To illustrate:
>=20
>=20
> =C2=A0DSL A <=3D=3D> Router/FW A <=3D=3D=3D=3D\
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (10.20.30.40/8) =C2=A0|
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 LAN Switch <=3D=3D> Server (10.9.8.7/8)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> =C2=A0DSL B <=3D=3D> Router/FW B <=3D=3D=3D=3D/
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (10.11.12.13/8)
>=20
>=20
> Until a couple of weeks ago, Router B was non-existent and both DSL lin=
es were connected to Router A. =C2=A0Circumstances forced me to setup rou=
ter B and connect DSL B to it. =C2=A0So now, previous
> traffic that flowed through DSL B to the server aren't routed properly,=
 but they have been rerouted through DSL A, so it is not a big concern ri=
ght now. =C2=A0I'm just wondering if there's a
> way to get traffic in DSL B bound for the server flowing back again wit=
h the new setup. =C2=A0If not, I can live with it.
>=20
>=20
>=20
> --- mike t.
>=20
>=20
> _______________________________________________________________________=
_________________________________________________________________________=
___________________________________________
> From: fooler mail <[email protected]>
> To: Michael Tinsay <tinsami1-/[email protected]>; Philippine Linux Users' Group =
(PLUG) Technical Discussion List <[email protected]>
> Sent: Sunday, 3 July 2016, 19:56
> Subject: Re: [plug] Recognizing traffic from multiple gateways
>=20
> ill give you an idea how to do it as im blind with your network topolog=
y
>=20
> linux can now have multiple virtual routing tables as well as multiple
> network namespaces.. this leads to virtualization in the OS layer such
> as LXC, Docker, etc...
>=20
> assuming your server have two network interface cards .. eth0
> connected to router A and eth1 connected to router B
>=20
> virtual routing table id is based on number..=C2=A0 we will make a mapp=
ing
> that virtual routing table id number to name.. just like in /etc/hosts
> but the file is /etc/iproute2/rt_tables:
>=20
> echo "200 routerA" >> /etc/iproute2/rt_tables
> echo "201 routerB" >> /etc/iproute2/rt_tables
>=20
> then create their default gateway for table routerA and table routerB:
>=20
> ip route add default via <router A gateway IP address> dev eth0 table r=
outerA
> ip route add default via <router B gateway IP address> dev eth1 table r=
outerB
>=20
> then you have to mark or tag the incoming packets for eth0 and eth1..
> we will tag all packets coming from eth0 as tag id 1 and all packets
> coming from eth1 as tag id 2:
>=20
> iptables -A PREROUTING -t mangle -i eth0 -j MARK --set-mark 1
> iptables -A PREROUTING -t mangle -i eth1 -j MARK --set-mark 2
>=20
> you can add specific destination protocol and port number of your
> server service in the iptables rule above to match specific packet...
>=20
> next is to add policy based routing rule:
>=20
> ip rule add from all fwmark 1 table routerA
> ip rule add from all fwmark 2 table routerB
>=20
> the above rule says:
>=20
> if outgoing packet tag as 1.. it will consult virtual routing table
> routerA.. because your default gateway is the router A gateway IP
> address.. it will send to router A...
> if outgoing packet tag as 2.. it will consult virtual routing table
> routerB.. because your default gateway is the router B gateway IP
> address.. it will send to router B...
>=20
> thats the basic of policy based routing...
>=20
> fooler.
>=20
>=20
>=20
>=20
> On Sat, Jul 2, 2016 at 1:37 AM, Michael Tinsay <tinsami1-/[email protected]> wro=
te:
> > Thank you for the info fooler.
> >
> > I get what you're saying about policy-based routing, but isn't that
> > applicable only to connections initiated by the server?=C2=A0 Can pol=
icy-based
> > routing also do "All connections initiated externally and coming thro=
ugh the
> > router ip address so-and-so goes through that router"?
> >
> >
> > ________________________________
> > From: fooler mail <[email protected]>
> > To: Michael Tinsay <tinsami1-/[email protected]>; Philippine Linux Users' Grou=
p
> > (PLUG) Technical Discussion List <[email protected]>
> > Sent: Saturday, 2 July 2016, 11:33
> > Subject: Re: [plug] Recognizing traffic from multiple gateways
> >
> > that is correct because traffic came from router A and B use the main
> > routing table... your solution is to use policy based routing....
> > create additional two routing table aside from the default or main
> > routing table.. for incoming traffic for A or B.... mark or tag it ..=
.
> > upon out going.. your policy rule state that packet tag for A goes to
> > gateway of=C2=A0 A and tag for B goes to gateway of B.. non tag packe=
ts
> > goes to the main routing table's default gateway...
> >
> > fooler.
> >
> >
> >
> > On Thu, Jun 30, 2016 at 3:05 AM, Michael Tinsay <tinsami1-/[email protected]> =
wrote:
> >> Ooops...=C2=A0 My bad. I sent the email without putting a subject.=C2=
=A0 Please
> >> reply
> >> to this one instead.
> >>
> >>
> >> ________________________________
> >> From: Michael Tinsay <tinsami1-/[email protected]>
> >> To: "Philippine Linux Users' Group (PLUG) Technical Discussion List"
> >> <[email protected]>
> >> Sent: Thursday, 30 June 2016, 15:03
> >> Subject:
> >>
> >> Hi.
> >>
> >> Have a question for the tcp/ip experts here.
> >>
> >> I recently had to split my various DSL lines between 2 routers. So R=
outer
> >> A
> >> have 3 lines connected to it while Router B has 2.=C2=A0 I now have =
a server
> >> who
> >> will be receiving external traffic through these servers via port
> >> forwarding.=C2=A0 As I understand it, without any additional configu=
ration the
> >> server will send outside-bound traffic through via the default route=
.=C2=A0 As
> >> such, if Router A is the default route for the server, even if the t=
raffic
> >> came from Router B the responses will be sent via Router A.
> >>
> >> If this is correct, what do I need to set up to have the server reco=
gnize
> >> which traffic is coming from which router and send its responses to =
the
> >> proper router accordingly?
> >>
> >> TIA!
> >>
> >>
> >> --- mike t.
> >
> >>
> >>
> >>
> >> _________________________________________________
> >> Philippine Linux Users' Group (PLUG) Mailing List
> >> http://lists.linux.org.ph/mailman/listinfo/plug
> >> Searchable Archives: http://archives.free.net.ph
> > _________________________________________________
> > Philippine Linux Users' Group (PLUG) Mailing List
> > http://lists.linux.org.ph/mailman/listinfo/plug
> > Searchable Archives: http://archives.free.net.ph
> >
> >
> >
> >
> > _________________________________________________
> > Philippine Linux Users' Group (PLUG) Mailing List
> > http://lists.linux.org.ph/mailman/listinfo/plug
> > Searchable Archives: http://archives.free.net.ph
>=20
>=20
>=20
>
---120695892-1567336435-1468334018=:17234
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph
---120695892-1567336435-1468334018=:17234--