Community discussions

MikroTik App
 
stefanosp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Tue Mar 01, 2011 1:01 pm
Location: Northern Italy

selective gateway

Thu Feb 14, 2013 5:58 pm

HI,
my router has two WAN IP addresses on the same physical port
and 5 LAN IP Addresses
/ip address> print 
Flags: X - disabled, I - invalid, D - dynamic 
 #   ADDRESS            NETWORK         INTERFACE                                                       
 0   192.168.10.2/24    192.168.10.0    ether4-LAN                                                      
 1   172.16.40.254/24   172.16.40.0     vlan-2                                                       
 2   172.16.50.254/24   172.16.50.0     vlan-1                                                                                                       
 5   37.xxx.xxx.237/29  37.xxx.xxx.232  ether1-WAN                                                      
 6   100.xx.xx.90/30    100.xx.xx.88    ether1-WAN    
gateways are 37.xxx.xxx.233 and 100.xx.xx.89

I need that all packets from 172.16.50.0/24 (or from interface vlan-1) and dst-address= 77.xxx.xxx.7 use gateway 100.xx.xx.89
all other packets must use gateway 37.xxx.xxx.233

What I Have to do, Please?

Thank you in advance

Stefano
 
User avatar
docmarius
Forum Guru
Forum Guru
Posts: 1222
Joined: Sat Nov 06, 2010 12:04 pm
Location: Timisoara, Romania
Contact:

Re: selective gateway

Thu Feb 14, 2013 9:45 pm

Mark all traffic from 172.16.50.0/24 and destination 77.xxx.xxx..7 with a routing mark (here you can be creative naming it), then add masquerade NAT rule and a default route for that mark with gateway 100.xx.xx.89.
I think you may also need to mark incoming traffic from 77.xxx.xxx..7 to 172.16.50.0/24 with that same routing mark and set up the proper routing for incoming traffic to match the masquerade rule (not sure about that, but it can't hurt).
For the default route of the unmarked packets set default gateway to 37.xxx.xxx.233.
 
stefanosp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Tue Mar 01, 2011 1:01 pm
Location: Northern Italy

Re: selective gateway

Fri Feb 15, 2013 9:54 am

Thank you for your answer

What I think to do:
/ip firewall mangle
add action=mark-routing chain=prerouting disabled=no dst-address=77.xxx.xxx.7 new-routing-mark=to_voip passthrough=yes \
    src-address=172.16.50.0/24
add action=mark-routing chain=prerouting disabled=no dst-address=172.16.50.0/24 new-routing-mark=to_voip passthrough=yes \
    src-address=77.xxx.xxx.7
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=100.xx.xx.89 routing-mark=to_voip scope=30 target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=37.xxx.xxx.233 scope=30 target-scope=10
is it right?
thank you
 
User avatar
docmarius
Forum Guru
Forum Guru
Posts: 1222
Joined: Sat Nov 06, 2010 12:04 pm
Location: Timisoara, Romania
Contact:

Re: selective gateway

Fri Feb 15, 2013 8:16 pm

Seems ok... Try it and see if it works :lol:
Maybe you need also routes defined for your gateways...
something like:
/ip route add dst-address=100.xx.xx.89/32 gateway=ether1-WAN distance=1
/ip route add dst-address=37.xxx.xxx.232/32 gateway=ether1-WAN distance=1
 
stefanosp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Tue Mar 01, 2011 1:01 pm
Location: Northern Italy

Re: selective gateway

Sun Feb 17, 2013 8:33 pm

Seems ok... Try it and see if it works :lol:
Maybe you need also routes defined for your gateways...
something like:

I tried a similar configuration at home, and it works.
Now I'll try on that router.
Thank you

Who is online

Users browsing this forum: fposavec and 66 guests