Community discussions

MikroTik App
 
darkingdoom
just joined
Topic Author
Posts: 2
Joined: Thu Oct 15, 2020 12:12 pm

Redirect specific domains to specific interface

Thu Oct 15, 2020 1:34 pm

Hey,
I have been experimenting lately with firewalls, DNS, NAT and mangle to do the following but no success
I want all requests from: *example.com* to go via specific interface, let's say if I have WAN1, WAN2, then I want it to go through WAN2
I don't want to add generic filter on http but on specific domains, can someone help what is the correct way to do it ?
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11627
Joined: Thu Mar 03, 2016 10:23 pm

Re: Redirect specific domains to specific interface

Thu Oct 15, 2020 1:56 pm

If you have more than one WAN address, then this should be done by configuring DNS records for your domain to use different WAN IP addresses for different (for internet users virtual) hosts. Router, as device accepting connections initiated by internet clients, can not do anything to redirect them, it can only either accept (and forward) them or block them.

E.g.:
www.example.com.    IN A 12.34.56.78
www2.example.com.   IN A 23.34.45.56
mail.example.com.   IN A 12.34.56.78
vpn.example.com.    IN A 23.34.45.56
...
 
darkingdoom
just joined
Topic Author
Posts: 2
Joined: Thu Oct 15, 2020 12:12 pm

Re: Redirect specific domains to specific interface

Thu Oct 15, 2020 2:13 pm

If you have more than one WAN address, then this should be done by configuring DNS records for your domain to use different WAN IP addresses for different (for internet users virtual) hosts. Router, as device accepting connections initiated by internet clients, can not do anything to redirect them, it can only either accept (and forward) them or block them.

E.g.:
www.example.com.    IN A 12.34.56.78
www2.example.com.   IN A 23.34.45.56
mail.example.com.   IN A 12.34.56.78
vpn.example.com.    IN A 23.34.45.56
...
Hey,
Thanks for the guidance
If possible, can you give me a command line commands based on the example rules you gave
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: Redirect specific domains to specific interface

Thu Oct 15, 2020 3:13 pm

I'd say the request was for outgoing connections to internet. It's possible if it's exact hostname (www.example.net). You can add it in IP firewall's address list and router will resolve it to IP address and also refresh it when TTL expires. You can then mark routing for packets with destination contained in the list. But if you need it for <anything>.example.net, where <anything> can be, well, anything, that's between problematic and impossible.

Who is online

Users browsing this forum: lurker888, STMT and 103 guests