I have a task where some IoT device needs to send emails (via some external email server, e.g. inbox.lv) and I plan on using LtAP Mini. Problem is this particular IoT device can reach external server only via IP address (it has no DNS client in it’s OS). Question: is it possible in RouterOS to forward all requests to that come to LtAP IP address to specific URL (e.g. mail.inbox.lv) from this IoT device (specify IoT device IP address + destination port as condition)? If so, please point me in the right direction ![]()
Many thanks in advance for help!
You can set server address on device to some fake unused one (e.g. 10.10.10.10) and create dstnat rule:
/ip firewall nat
add chain=dstnat dst-address=10.10.10.10 protocol=tcp dst-port=25 action=dst-nat to-addresses=1.2.3.4 comment=someuniqueid
But you can’t use hostname in to-addresses, so you need a script to update it (run it from scheduler with some reasonable frequency):
:local Host "mail.inbox.lv"
:do {
:local NewIP [:resolve $Host]
/ip firewall nat set [find comment="someuniqueid"] to-addresses=$NewIP
} on-error={
:log info "unable to resolve $Host"
}
Thank you very much for answer - will test this out and come back!