Community discussions

MikroTik App
 
nerdtron
Member Candidate
Member Candidate
Topic Author
Posts: 123
Joined: Sat Nov 30, 2013 7:49 am

2 LAN 2 gateways

Wed Dec 18, 2013 3:05 am

So I have two seperate LAN, 192.168.1.0/24 (lan1) and 192.168.2.0/24 (lan2). I also have two gateway (internet) on port1 and port2 of the RB951.
I want to make all lan1 have a gateway to port1 and all lan2 have a gateway to port2?
How can I approach this?
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 557
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: 2 LAN 2 gateways

Wed Dec 18, 2013 8:44 am

http://wiki.mikrotik.com/wiki/Load_Bala ... e_Gateways

Send from my mobile phone using Tapatalk.
 
nerdtron
Member Candidate
Member Candidate
Topic Author
Posts: 123
Joined: Sat Nov 30, 2013 7:49 am

Re: 2 LAN 2 gateways

Wed Dec 18, 2013 10:36 am

That is exactly what I followed before posting here. Almost the same setup, only difference on mine is lan1 is from the lan ports (3-5 interface) and lan2 is the wlan1 interface.

But fail, is that tutorial even working or I need to add more config that is not mentioned on the tutorial??
 
Rudios
Forum Veteran
Forum Veteran
Posts: 973
Joined: Mon Mar 11, 2013 12:58 pm
Location: The Netherlands

Re: 2 LAN 2 gateways

Wed Dec 18, 2013 12:52 pm

Post your export so we can have a look.

And since you seem to have 2 /24 segments, you should have 2 NAT masquerade rules.
 
User avatar
nickshore
Long time Member
Long time Member
Posts: 521
Joined: Thu Mar 03, 2005 4:14 pm
Location: Suffolk, UK.
Contact:

Re: 2 LAN 2 gateways

Wed Dec 18, 2013 1:47 pm

You can do this simply using Routing Rules

In winbox go to IP Routes

Add default routes with routing marks eg wan1 and wan2, specify the gateway on each one.

then go to the Rules tab

Then add rules for each subnet, using the src address of the lan, action of lookup and table specifies the routing mark.

Hope that helps
Nick.
 
nerdtron
Member Candidate
Member Candidate
Topic Author
Posts: 123
Joined: Sat Nov 30, 2013 7:49 am

Re: 2 LAN 2 gateways

Thu Dec 19, 2013 4:28 am

Rudios, I am aware of that, thanks for the reminder. Here is my export:

#lan1 is 192.168.14.0/24 network
#wifi network is 192.168.15.0/24
#wan1 gateway is 192.168.20.1
#wan2 gateway is 192.168.46.1

Basically I want all wifi to pass on wan2, and I want all lan1 to pass on wan1
/interface ethernet
set [ find default-name=ether1 ] name=port1
set [ find default-name=ether2 ] name=port2
set [ find default-name=ether3 ] name=port3
set [ find default-name=ether4 ] master-port=port3 name=port4
set [ find default-name=ether5 ] master-port=port3 name=port5
/interface wireless
set [ find default-name=wlan1 ] default-ap-tx-limit=1024000 disabled=no l2mtu=2290 mode=ap-bridge
/ip hotspot user profile
set [ find default=yes ] idle-timeout=none keepalive-timeout=2m mac-cookie-timeout=3d
/ip pool
add name=dhcp_pool1 ranges=192.168.15.50-192.168.15.200
/ip dhcp-server
add address-pool=dhcp_pool1 disabled=no interface=wlan1 lease-time=6h name=server1
/ip address
add address=192.168.15.1/24 comment=wifi interface=wlan1 network=192.168.15.0
add address=192.168.46.100/24 comment=wan2 interface=port2 network=192.168.46.0
add address=192.168.20.100/24 comment=wan1 interface=port1 network=192.168.20.0
add address=192.168.14.100/24 comment=lan interface=port3 network=192.168.14.0
/ip dhcp-server network
add address=192.168.15.0/24 dns-server=208.67.222.222,208.67.220.220 gateway=192.168.15.1 netmask=24
/ip dns
set allow-remote-requests=yes servers=208.67.222.222,208.67.220.220
/ip firewall mangle
add action=mark-routing chain=prerouting comment=lan-to-wan1 new-routing-mark=to_wan1 passthrough=no src-address=192.168.14.0/24
add action=mark-routing chain=prerouting comment=wifi_to_wan2 new-routing-mark=to_wan2 passthrough=no src-address=192.168.15.0/24
/ip firewall nat
add action=masquerade chain=srcnat src-address=192.168.14.0/24
add action=masquerade chain=srcnat src-address=192.168.15.0/24
/ip route
add distance=1 gateway=192.168.20.1 routing-mark=to_wan1
add distance=1 gateway=192.168.46.1 routing-mark=to_wan2
/system leds
set 0 interface=wlan1
nickshore, I'm new to routing rules, can you elaborate more?
Do you mean this? http://blog.butchevans.com/2008/09/mikr ... n-example/
I can't make it work either.
 
nerdtron
Member Candidate
Member Candidate
Topic Author
Posts: 123
Joined: Sat Nov 30, 2013 7:49 am

Re: 2 LAN 2 gateways

Thu Dec 19, 2013 5:15 am

OK, I think I made some progress, instead of just src-address in the mangle rules, I made it src-address-list and then added firewall address-list.
/ip firewall address-list
add address=192.168.14.0/24 list=lan-users
add address=192.168.15.0/24 list=wifi-users
/ip firewall mangle
add action=mark-routing chain=prerouting comment=lan-to-wan1 new-routing-mark=to_wan1 passthrough=no src-address-list=lan-users
add action=mark-routing chain=prerouting comment=wifi_to_wan2 new-routing-mark=to_wan2 passthrough=no src-address-list=wifi-users
ping from lan1 goes to wan1 and ping from wifi goes to wan2.
It seems to be working, (but I needed more tests), and is this really the traceroute that I should expect?
D:\Documents and Settings\Administrator>tracert 8.8.8.8

Tracing route to 8.8.8.8 over a maximum of 30 hops

  1  4294967294 ms  4294967294 ms  4294967294 ms  192.168.14.100
  2     1 ms  4294967294 ms  4294967294 ms  192.168.20.1
  3    78 ms    76 ms    76 ms  10.198.140.89
  4   467 ms    66 ms    96 ms  10.198.140.90
     ...........

Who is online

Users browsing this forum: Google [Bot], loloski, maldridge and 98 guests