Community discussions

MikroTik App
 
nikc
Member Candidate
Member Candidate
Topic Author
Posts: 204
Joined: Wed Jul 13, 2016 6:05 pm

Force Traffic via specific interface

Sun Jan 23, 2022 9:03 pm

On one of my ROS 6.49.1 units i have a simple solution to force all traffic from a fixed IP out via a specific interface:
Mangle rule
0 ;;; Send laptop via 4G
chain=prerouting action=mark-routing new-routing-mark=BT4G passthrough=yes src-address=192.168.0.241 dst-address-list=!<lan_list> log=no log-prefix=""
Routing rule
/ip route
add check-gateway=ping distance=1 gateway=192.168.0.254 routing-mark=BT4G
I have two questions:
1. How would I achieve the same in ROS 7 - it seems to work somewhat differently ?
2. Would it be possible to use a rule similar to the above but instead of specifying a source IP, it would be a dst port ?

Thanks
 
Sob
Forum Guru
Forum Guru
Posts: 8189
Joined: Mon Apr 20, 2009 9:11 pm

Re: Force Traffic via specific interface

Sun Jan 23, 2022 10:13 pm

1. Routing tables in v7 are not created automatically, you need to create them yourself in /routing/table/.
2. Yes, just change mangle rule's conditions.
Come on people, do you really have to quote full posts? It's annoying and in most cases useless.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 11768
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Force Traffic via specific interface

Mon Jan 24, 2022 6:53 pm

Three configuration steps!

/routing table add name=BT4G fib

/ip route
add dst=0.0.0.0/0 gateway=4G_gateway table=BT4G

/routing rule
add action=lookup-only-in-table src-address=192.168.0.241/32 table=BT4G

++++++++++++++++++++++++
Summary: In this situation, the single IP address/user for all their traffic will be forced out the 4G gateway. There is no need for mangles, postrouting etc.......
If you want the user to be able to access the MAIN WAN, if the 4G connection fails, then use the ACTION= "lookup"
I'd rather manage rats than software. Follow my advice at your own risk! (Sob & mkx forced me to write that!)
MTUNA Certified, by the Ascerbic Llama!
 
nikc
Member Candidate
Member Candidate
Topic Author
Posts: 204
Joined: Wed Jul 13, 2016 6:05 pm

Re: Force Traffic via specific interface

Tue Jan 25, 2022 11:09 am

Three configuration steps!

/routing table add name=BT4G fib

/ip route
add dst=0.0.0.0/0 gateway=4G_gateway table=BT4G

/routing rule
add action=lookup-only-in-table src-address=192.168.0.241/32 table=BT4G

++++++++++++++++++++++++
Summary: In this situation, the single IP address/user for all their traffic will be forced out the 4G gateway. There is no need for mangles, postrouting etc.......
If you want the user to be able to access the MAIN WAN, if the 4G connection fails, then use the ACTION= "lookup"
Thank you so much for sharing this, makes a bit more sense now.
Will test this today, do you know if there is a way to do this based on src / dst port ?

Thanks again
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 11768
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Force Traffic via specific interface

Tue Jan 25, 2022 11:20 am

Not that I am aware of, the choices in route rule are limited but my experience is commensurately limited as well.
I'd rather manage rats than software. Follow my advice at your own risk! (Sob & mkx forced me to write that!)
MTUNA Certified, by the Ascerbic Llama!
 
Sob
Forum Guru
Forum Guru
Posts: 8189
Joined: Mon Apr 20, 2009 9:11 pm

Re: Force Traffic via specific interface

Tue Jan 25, 2022 7:21 pm

Routing works with addresses. If you want ports, stick with mangle rules.
Come on people, do you really have to quote full posts? It's annoying and in most cases useless.

Who is online

Users browsing this forum: winap and 6 guests