I am replacing a relatively simple DSL Modem/Router with an RB5009. I have the basics working but now I need to get the NAT table moved to allow me to use my NAS and some other devices that are externally accessible. Mostly by SNMP.
There seems to be a plethora of options in the firewall NAT section of Winbox or the browser interface. If someone could give me a sample of how to enter one of these, particularly the ones that have a range of ports, that would be super helpful.
IPv4 port forwarding in RouterOS is done using rules in the IP -> Firewall -> NAT table with chain=dstnat and action=dst-nat, as you can read here.
First, if you don't have a static public IP address pointing to your router, but only a dynamic one, you should create an address list entry that will has the public IP address that points to the router. You can add using the GUI by going to IP -> Firewall -> Address Lists, or enter this command in the Terminal in WinBox:
(adjust your.domain.name of course). But if you have a fully static IP address, for example 123.45.67.89, then replacedst-address-list=PUBLIC_IP in the example commands below with dst-address=123.45.67.89 instead.
Here is the example DSTNAT rules that implement the two "Wally Cam" entries in your screenshot:
Again, you need two separate rules for UDP and TCP, and with to-ports you can change the destination port (this also accepts a port range/enumeration).
You can create those rules with the GUI in WinBox, but it's probably faster to create them first in a text editor then just copy the commands and paste them in the terminal.
After you've created the rules, port forwarding will work from the outside (from the internet). But the functionality of the "LAN Loopback" column in your table is not yet replicated. That is what called Hairpin-NAT in the MikroTik documentation. Without LAN Loopback / Hairpin-NAT, accessing the port forwarded resources using the public IP address / public domain name from inside the same LAN subnet is not possible. You can add this rule to enable Hairpin-NAT and replicate "LAN Loopback = Enabled". We only add one single rule for the whole 192.168.1.0/24 subnet though, and enable it for all:
We need these examples of wonderfully provided explanations and examples readily available.
No idea how to do that without it quickly getting hidden in heaps of discussion and comments and variations and other excellent, helpful, and concise explanations.
If you have single public IP address and don't need to connect to [public IP]:[port] from inside your LAN, then alternative (a better one IMO) would be to use in-interface-list=WAN instead of dst-address-list (or dst-address). This way the NAT table better aligns with default firewall filter rule set (which extensively uses WAN interface list as filtering property).
Exactly! But to replicate the table which has LAN Loopback enabled I needed to assume that access from inside with the domain name was needed.
If port forwarding was only needed for things like XBOX live to work (that's my only use for DSTNAT at home) then using in-interface-list=WAN is the preferred way.
Please don't open up ports of internet facing interfaces with the old nat port-forwarding technique.
Use a newer way to handle this situation, i.e. a VPN tunnel into your private network (Home lab), so that you only need to open up "one secure" VPN port.
Do you mean when pasting the commands? In RouterOS normally commands are limited by new lines (or ;), if you want a command to span multiple lines, you'll need to join the lines with \ (see the examples above). If you miss a \ then you might cause the command to be split into two invalid commands. When pasting commands into the terminal, check if there are error messages. If yes, try pasting the command one by one.
To be clear, I set up the hair pin assuming it was the same as loopback on more consumer routers.
On those routers you can test port forward from the outside from the inside if loopback is enabled.
If that is not correct please let me know.
Port forwarding from the outside is NOT working. I have attached a config file.
Please paste the config using the “Preformatted Text” block, which is denoted above by the “</>” icon.
I am not certain, but I would want to run separate tests on (1) port forwarding from the outside – i.e., from a remote location connected only by the public internets and (2) hairpin from within the network. That is, I would not try to run only 1 test to confirm both work.
Are you sure that your public WAN IP address is 127.72.201.163? As per RFC5735, whole 127.0.0.0/8 is reserved for host loopback addresses ... so they really shouldn't be used for connections between different machines. And shouldn't be routed around.