Page 1 of 1

3 WAN - 1 LAN

Posted: Tue Aug 23, 2011 3:38 pm
by brainscan
Hi,

I`ve just brought a mikrotik router board 493AH..I have winbox but I dont really know how to do a setup...
I`ve a 3 WAN on my lan one is 192.168.1.254, 192.168.1.252 and 192.168.1.200 how can I setup up these gateways on my LAN...? I would like to IPs from 192.168.1.1 - 192.168.1.100 use the first gateway 192.168.1.101 - 192.168.1.200 to use the second one and the rest to use the third gateway. I hope someone can help me. Thank you.


edit:

If you can tell me how to do it under telnet that would be ok too.. Thanks again.

Re: 3 WAN - 1 LAN

Posted: Tue Aug 23, 2011 3:50 pm
by Feklar
Look up and read on policy based routing. Several examples in the wiki and man examples in the forum. It is a question that comes up often.

Re: 3 WAN - 1 LAN

Posted: Wed Aug 24, 2011 1:21 am
by routik
If you're not using hotspot, this may help http://wiki.mikrotik.com/wiki/Load_Bala ... e_Gateways

Re: 3 WAN - 1 LAN

Posted: Tue Aug 30, 2011 1:29 pm
by brainscan
Thank you.

Re: 3 WAN - 1 LAN

Posted: Wed Aug 31, 2011 11:47 am
by brainscan
I cant even setup a basic router function ... how can I add only one gateway? For eth1 I add 192.168.1.254 one of my gateway ... eth2 goes to switch where is my rest of the LAN, I have added addresses to the ports ... I did setup the dns and the firewall too... :(

Re: 3 WAN - 1 LAN

Posted: Wed Aug 31, 2011 7:11 pm
by MCT
A diagram would help people assist you.

What are the 3 WAN devices and how do they connect upstream?
How are they physically connected from the WAN devices to the Routerboard? Is there a switch?

Re: 3 WAN - 1 LAN

Posted: Wed Aug 31, 2011 9:07 pm
by brainscan
Thanks for the reply... This is the currently network diagramm
1.jpg
and this is what I would like to achieve
2.jpg
GW1 is a wireless link to the internet with fix public IP
GW2 is also a wireless link to the internet with fix public IP
GW3 is a simple ADSL connection

Re: 3 WAN - 1 LAN

Posted: Wed Aug 31, 2011 9:30 pm
by fewi
That doesn't make any sense to me. Do you mean you want the 3 existing gateways so somehow connect to the Internet, the Mikrotik router to connect to those three gateways, and have the Mikrotik router be the only router on the LAN?

Re: 3 WAN - 1 LAN

Posted: Thu Sep 01, 2011 12:31 am
by brainscan
Exactly...The whole traffic should go through the Mikrotik...

Re: 3 WAN - 1 LAN

Posted: Thu Sep 01, 2011 1:13 am
by fewi
I'm bored so I'll type this out. All of this is documented in the manuals.

Connect gw1 to the Internet on its WAN port. Configure its LAN port as 172.31.255.254/30. Add a route to 192.168.1.0/24 via 172.31.255.253.
Connect gw2 to the Internet on its WAN port. Configure its LAN port as 172.31.255.250/30. Add a route to 192.168.1.0/24 via 172.31.255.249.
Connect gw3 to the Internet on its WAN port. Configure its LAN port as 172.31.255.246/30. Add a route to 192.168.1.0/24 via 172.31.255.245.

Connect gw1's LAN port to ether1 on the RouterBOARD. Configure an IP address of 172.31.255.253 on ether1.
Connect gw2's LAN port to ether1 on the RouterBOARD. Configure an IP address of 172.31.255.249 on ether2.
Connect gw3's LAN port to ether1 on the RouterBOARD. Configure an IP address of 172.31.255.245 on ether3.
Connect your LAN switch to ether4 on the RouterBOARD. Configure an IP address of 192.168.1.1 on ether4.
/ip address
add address=172.31.255.253 interface=ether1
add address=172.31.255.249 interface=ether2
add address=172.31.255.245 interface=ether3
add address=192.168.1.1/24 interface=ether4
Configure policy routing mangle rules that mark traffic going from the LAN to the Internet based on the LAN host source address, these marks assign traffic to one of the three gateways.
/ip firewall address-list
add list=rfc1918 address=192.168.0.0/16
add list=rfc1918 address=172.16.0.0/12
add list=rfc1918 address=10.0.0.0/8
/ip firewall mangle
add chain=prerouting src-address-list=rfc1918 dst-address-list=rfc1918 action=accept
add chain=prerouting src-address=192.168.1.2-192.168.1.100 action=mark-routing new-routing-mark=to-gw1
add chain=prerouting src-address=192.168.1.101-192.168.1.200 action=mark-routing new-routing-mark=to-gw2
add chain=prerouting src-address=192.168.1.201-192.168.1.154 action=mark-routing new-routing-mark=to-gw3
/ip route 
add dst-address=0.0.0.0/0 routing-mark=to-gw1 gateway=172.31.255.254 
add dst-address=0.0.0.0/0 routing-mark=to-gw2 gateway=172.31.255.250
add dst-address=0.0.0.0/0 routing-mark=to-gw3 gateway=172.31.255.246 
add dst-address=0.0.0.0/0 gateway=172.31.255.254 distance=1
add dst-address=0.0.0.0/0 gateway=172.31.255.250 distance=2
add dst-address=0.0.0.0/0 gateway=172.31.255.246 distance=3
If gw1-3 can't NAT networks not directly connected to them add NAT rules (though this will cause double NAT, which is fairly ugly):
/ip firewall nat
add chain=srcnat out-interface=ether1 action=src-nat to-address=172.31.255.253
add chain=srcnat out-interface=ether2 action=src-nat to-address=172.31.255.249
add chain=srcnat out-interface=ether3 action=src-nat to-address=172.31.255.245
Of course this doesn't cover things like DNS, or a DHCP server on the RouterBOARD. Those topics are fundamental and adequately covered by the manual.

Re: 3 WAN - 1 LAN

Posted: Thu Sep 01, 2011 9:55 am
by brainscan
Thank you, I`ll try this. I dont need dhcp we use only static IPs.

Re: 3 WAN - 1 LAN

Posted: Thu Sep 01, 2011 3:34 pm
by d33cktr4zy
I'm bored so I'll type this out. All of this is documented in the manuals.

Connect gw1 to the Internet on its WAN port. Configure its LAN port as 172.31.255.254/30. Add a route to 192.168.1.0/24 via 172.31.255.253.
Connect gw2 to the Internet on its WAN port. Configure its LAN port as 172.31.255.250/30. Add a route to 192.168.1.0/24 via 172.31.255.249.
Connect gw3 to the Internet on its WAN port. Configure its LAN port as 172.31.255.246/30. Add a route to 192.168.1.0/24 via 172.31.255.245.

Connect gw1's LAN port to ether1 on the RouterBOARD. Configure an IP address of 172.31.255.253 on ether1.
Connect gw2's LAN port to ether1 on the RouterBOARD. Configure an IP address of 172.31.255.249 on ether2.
Connect gw3's LAN port to ether1 on the RouterBOARD. Configure an IP address of 172.31.255.245 on ether3.
Connect your LAN switch to ether4 on the RouterBOARD. Configure an IP address of 192.168.1.1 on ether4.
/ip address
add address=172.31.255.253 interface=ether1
add address=172.31.255.249 interface=ether2
add address=172.31.255.245 interface=ether3
add address=192.168.1.1/24 interface=ether4
Configure policy routing mangle rules that mark traffic going from the LAN to the Internet based on the LAN host source address, these marks assign traffic to one of the three gateways.
/ip firewall address-list
add list=rfc1918 address=192.168.0.0/16
add list=rfc1918 address=172.16.0.0/12
add list=rfc1918 address=10.0.0.0/8
/ip firewall mangle
add chain=prerouting src-address-list=rfc1918 dst-address-list=rfc1918 action=accept
add chain=prerouting src-address=192.168.1.2-192.168.1.100 action=mark-routing new-routing-mark=to-gw1
add chain=prerouting src-address=192.168.1.101-192.168.1.200 action=mark-routing new-routing-mark=to-gw2
add chain=prerouting src-address=192.168.1.201-192.168.1.154 action=mark-routing new-routing-mark=to-gw3
/ip route 
add dst-address=0.0.0.0/0 routing-mark=to-gw1 gateway=172.31.255.254 
add dst-address=0.0.0.0/0 routing-mark=to-gw2 gateway=172.31.255.250
add dst-address=0.0.0.0/0 routing-mark=to-gw3 gateway=172.31.255.246 
add dst-address=0.0.0.0/0 gateway=172.31.255.254 distance=1
add dst-address=0.0.0.0/0 gateway=172.31.255.250 distance=2
add dst-address=0.0.0.0/0 gateway=172.31.255.246 distance=3
If gw1-3 can't NAT networks not directly connected to them add NAT rules (though this will cause double NAT, which is fairly ugly):
/ip firewall nat
add chain=srcnat out-interface=ether1 action=src-nat to-address=172.31.255.253
add chain=srcnat out-interface=ether2 action=src-nat to-address=172.31.255.249
add chain=srcnat out-interface=ether3 action=src-nat to-address=172.31.255.245
Of course this doesn't cover things like DNS, or a DHCP server on the RouterBOARD. Those topics are fundamental and adequately covered by the manual.
Lol, @fewi. He can be bored to. (Its boring as it a repetitive question) Acctually, this topic has been scatteredly discussed on many thread and some mikrotik forum.

Try googling with "mikrotik load balancing multiple gateway" you'll see bunch discussion and tutorials.

More, if you would like to use multiple gateway, perhaps you can apply pcc load balancing.


Sent from my BlackBerry 9300 using Tapatalk