|
| |||||||||
Quick Start for Impatient Configuration export from the gateway router: / ip address add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 \ / ip firewall mangle add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \ / ip firewall nat add chain=srcnat connection-mark=odd action=src-nat to-addresses=10.111.0.2 \ / ip route add dst-address=0.0.0.0/0 gateway=10.111.0.1 scope=255 target-scope=10 \ Explanation First we give a code snippet and then explain what it actually does. Mangle : / ip address add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 \ The router has two upstream (WAN) interfaces with the addresses of 10.111.0.2/24 and 10.112.0.2/24. The LAN interface has the name "Local" and IP address of 192.168.0.1/24. /ip firewall mangle add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \ First we take every second packet that establishes new session (note connection-state=new), and mark it with connection mark "odd". Consequently all successive packets belonging to the same session will carry the connection mark "odd". Note that we are passing these packets to the second rule (passthrough=yes) to place a routing mark on these packets in addition to the connection mark. add chain=prerouting in-interface=Local connection-mark=odd action=mark-routing \ The rule above places the routing mark "odd" on all packets that belong to the "odd" connection and stops processing all other mangle in prerouting chain rules for these packets. add chain=prerouting in-interface=Local connection-state=new nth=1,1,1 \ These rules do the same for the remaining half of the traffic as the first two rules for the first half of the traffic. The code above effectively means that each new connection initiated through the router from the local network will be marked as either "odd" or "even" with both routing and connection marks.
NAT / ip firewall nat add chain=srcnat connection-mark=odd action=src-nat to-addresses=10.111.0.2 \ All traffic marked "odd" is being NATted to source IP address of 10.111.0.2, while traffic marked "even" gets "10.112.0.2" source IP address. Routing. / ip route add dst-address=0.0.0.0/0 gateway=10.111.0.1 scope=255 target-scope=10 \ For all traffic marked "odd" (consequently having 10.111.0.2 translated source address) we use 10.111.0.1 gateway. In the same manner all traffic marked "even" is routed through the 10.112.0.1 gateway. Finally, we have one additional entry specifying that traffic from the router itself (the traffic without any routing marks) should go to 10.112.0.1 gateway. Reference : Mikrotik Wiki
Bookmark
Email This
Hits: 818 Trackback(0)
Comments (0)
![]() Write comment
|
| Members | 4 |
| Content | 38 |
| Web Links | 23 |
| Content View Hits | 22.972 |