I am still new to Mikrotik, so I am hoping I can define my question properly
I have a simple network using RB951Ui 6.18
WAN – ether1 (DDNS – “mydomain.com”)
LAN – Bridge (ether2-5 and wlan1) 172.16.80.10/24
I have two test servers with static IPs
Server1 172.16.80.40:808
Server2 172.16.80.41:809
Here is my NAT section
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
add action=dst-nat chain=dstnat dst-port=808 in-interface=ether1 protocol=tcp to-addresses=172.16.80.40
add action=dst-nat chain=dstnat dst-port=809 in-interface=ether1 protocol=tcp to-addresses=172.16.80.41
as the tutorial shows but that doesn’t give me any different result. I still get “This webpage is not available” when I type mydomain.com:808 or mydomain.com:809 in the browser.
(bridge-local interface is my LAN bridge (ether2-5 and wlan1))
well, are you hoping to access these servers via their internal IP or their external? if you are OK using internal, why not just add these hosts to your internal DNS?
Actually He/She found if before me so I should give him/her all the credit.
The solution is not to use in-interface=ether1, but dst-address-type=local in the dst-nat section.
So here is my NAT section after the changes:
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
add action=dst-nat chain=dstnat dst-port=808 dst-address-type=local protocol=tcp to-addresses=172.16.80.40
add action=dst-nat chain=dstnat dst-port=809 dst-address-type=local protocol=tcp to-addresses=172.16.80.41
I was suggesting using internal DNS to resolve to internal IP of those hosts to the FQDN name. This achieves your goal if you want to hit your server on it’s internal IP.
Seems like that in-interface=ether1 was stopping me from accessing mydomain.com:port from the inside. Using either dst-address=(my WAN IP) or dst-address-type=local is giving me access.
The only issue that I see when using dst-address=(my WAN IP) is that my WAN IP is dynamic and if my ISP change it I have to change it in my NAT rules. I am sure I can write a script to get my IP and put it in address list.
Which way do you think is better: Using dst-address=(my WAN IP) or dst-address-type=local ?
Yes this would work great if I had only one server for that domain. Then I can add static mydomain.com → 172.16.80.40
How do I do it for two or more servers with one domain name?
Yes this would work great if I had only one server for that domain. Then I can add static mydomain.com → 172.16.80.40
How do I do it for two or more servers with one domain name?
I see. of course you are correct. A DNS can’t resolve to a set of IP’s based on the port you will attempt to connect to after the name is resolved