Community discussions

MUM Europe 2020
 
User avatar
GWISA-Kroonstad
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Fri Nov 10, 2006 3:34 pm

Different Subnets... Different gateways...

Tue Aug 14, 2007 8:29 pm

I have a situation:

2 Local subnets (Subnet1 and Subnet2) need to access the internet through the same MT PC, yet using different gateways.
Required to set Routing to direct each Local IP range to the Correct Gateway.

Setup ot the MT Unit: 1 Wlan and 1 Ethernet
The WLAN is in bridge mode with (dynamic)WDS enabled on Bridge1.
The Bridge1 Interface has Ether1 and WDS(dynamic) as ports.
Ether1 connects to a switching-hub. To this hub connects PC1 and two Internet Routers(Gateways) (Router1 and Router2)

PC1 has an IP on the same range as Subnet1.
There are 4 IP addresses set to Interface Bridge1 on the MT unit:
IP1 is the gateway of local Subnet1
IP2 is the gateway of local subnet2
IP3 is on the same range as Router1
IP4 is on the same range as Router2

Masquerade: Two rules set: One for srcaddress=subnet1 and one for srcaddress=subnet2

Routing Marks:
In Mangle two routing marks are set: One for srcaddress=subnet1 (Routing Mark=Subnet1Route)
and one for srcaddress=subnet2 (Routing-Mark=Subnet2Route)

In IP Routes:

Setting1
Two routes set:
Routing Mark = Subnet1Route => gateway = Router1 IP
Routing Mark = Subnet2Route => gateway = Router2 IP

Setting2
Alternative setup:
Default Gateway => Router1 IP
Routing Mark = Subnet2Route => gateway = Router2 IP

In Both settings, the gateway allocation works correctly.

Problem
In Both settings, PCs from different subnets can access each other until the routing rules are enabled.
In the Setting1, PC1 can access subnet1 until the routing rules are enabled. In the second setting, PC1 can access subnet1.

Any advice? Any better approach for gateway allocation? Thx
Last edited by GWISA-Kroonstad on Wed Aug 15, 2007 12:45 am, edited 1 time in total.
 
User avatar
tneumann
Member
Member
Posts: 394
Joined: Sat Apr 16, 2005 6:38 pm
Location: Germany

Re: Different Subnets... Different gateways...

Tue Aug 14, 2007 11:37 pm

Set the routing marks not only depending on the source-address but also on the destination-address, that is only set the subnet1 routing mark if the destination-address is not in subnet2 and set the subnet2 routing mark only if the destination-address is not in subnet1. Something like
add chain=prerouting action=mark-routing new-routing-mark=subnet1route passthrough=yes src-address={SUBNET1_HERE} dst-address=!{SUBNET2_HERE}
--Tom
 
User avatar
GWISA-Kroonstad
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Fri Nov 10, 2006 3:34 pm

Re: Different Subnets... Different gateways...

Wed Aug 15, 2007 12:43 am

Thx Tom... Will try and report.

http://wiki.mikrotik.com/wiki/Policy_Ro ... erOS_2.9.x

Wonder what the 3rd rule is for? Lookup?
 
User avatar
GWISA-Kroonstad
Member Candidate
Member Candidate
Topic Author
Posts: 111
Joined: Fri Nov 10, 2006 3:34 pm

Re: Different Subnets... Different gateways...

Wed Aug 15, 2007 8:20 pm

Thx again Tom.

Tried your suggestion.
PC1 is now able to access Subnet1, but not Subnet2, even when the MT IP is set as gateway for PC1. Masquerading applied.

Yet, we need to know is there a working way in MT where we can allocate two different gateways to two different subnets respectively, and through only one bridge interface?
 
User avatar
GWISA
Member
Member
Posts: 394
Joined: Tue Jan 31, 2006 2:37 pm
Location: Johannesburg, South Africa

Re: Different Subnets... Different gateways...

Fri Aug 17, 2007 1:27 am

This option should work fine
Default Gateway => Router1 IP
Routing Mark = Subnet2Route => gateway = Router2 IP; !subnet1
Use IP route with routing mark, and add the third rule in your ip routes rules - routing mark=table, action lookup

Who is online

Users browsing this forum: Kindis, philipaps and 133 guests