Mikrotik пробросить 443 порт

Перенаправление запросов (проброс портов) на Mikrotik

Инструкция описывает процесс настройки перенаправления сетевых запросов с внешнего подключения на компьютеры в локальной сети.

Настройка проброса

Переходим по разделам IPFirewallNATAdd New:

Далее настройка выполняется в зависимости от того, какой сервис нужно опубликовать.

Примеры пробросов

RDP (удаленный рабочий стол)

  • Chain — dstnat;
  • Dst. Address — внешний IP-адрес;
  • Protocol — rdp;
  • Action — dst-nat;
  • To Address — IP-адрес сервера, на который должно идти перенаправление.


* если данная настройка не сработает, меняем протокол на tcp и задаем порт RDP — по умолчанию, 3389.

WWW (80 или веб-сервер или http)

  • Chain — dstnat;
  • Dst. Address — внешний IP-адрес;
  • Protocol — tcp;
  • Dst. Port — 80;
  • Action — dst-nat;
  • To Address — IP-адрес сервера, на который должно идти перенаправление.


HTTPS

Настройка та же, что для 80 порта, но в место 80 пишем 443.

  • Chain — dstnat;
  • Dst. Address — внешний IP-адрес;
  • Protocol — tcp;
  • Dst. Port — 20,21;
  • Action — dst-nat;
  • To Address — IP-адрес сервера, на который должно идти перенаправление.


Видеонаблюдение

Системы видеонаблюдения могут работать на различных портах, поэтому первым делом обращаемся к инструкции системы, с которой необходимо работать.

В данном примере рассмотрим проброс RTSP.

  • Chain — dstnat;
  • Dst. Address — внешний IP-адрес;
  • Protocol — udp;
  • Dst. Port — 554;
  • Action — dst-nat;
  • To Address — IP-адрес сервера, на который должно идти перенаправление.


* RTSP работает по протоколам TCP и UDP. В данном примере правило настроено для последнего.

Почтовая система Zimbra

Для нормальной работы почтовой системы необходимо пробросить следующие порты:

  • 25 — основной порт для обмена почтой по протоколу SMTP.
  • 80 — веб-интерфейс для чтения почты (http).
  • 110 — POP3 для загрузки почты.
  • 143 — IMAP для работы с почтовым ящиком с помощью клиента.
  • 443 — SSL веб-интерфейс для чтения почты (https).
  • 465 — безопасный SMTP для отправки почты с почтового клиента.
  • 587 — SMTP для отправки почты с почтового клиента (submission).
  • 993 — SSL IMAP для работы с почтовым ящиком с помощью клиента.
  • 995 — SSL POP3 для загрузки почты.
  • 5222 — для подключения к Zimbra по протоколу XMPP.
  • 5223 — для защищенного подключения к Zimbra по протоколу XMPP.
  • 7071 — для защищенного доступа к администраторской консоли.
  • 8443 — SSL веб-интерфейс для чтения почты (https).
  • 7143 — IMAP для работы с почтовым ящиком с помощью клиента.
  • 7993 — SSL IMAP для работы с почтовым ящиком с помощью клиента.
  • 7110 — POP3 для загрузки почты.
  • 7995 — SSL POP3 для загрузки почты.
  • 9071 — для защищенного подключения к администраторской консоли.

Важно отметить, что не все перечисленные порты понадобятся именно вам. Если мы не планируем использовать POP3, то и соответствующие порты для него пробрасывать не нужно.

Сама настройка на микротике будет такой:

  • Chain — dstnat;
  • Dst. Address — внешний IP-адрес;
  • Protocol — tcp;
  • Dst. Port — 25,80,110,143,443,465,587,993,995,5222,5223,9071,7071,8443,7143,7993,7110,7995;
  • Action — dst-nat;
  • To Address — IP-адрес сервера, на который должно идти перенаправление.

Источник

Проброс портов в MikroTik

Нередко у нас возникает необходимость дать доступ снаружи к компьютерам, которые находятся за NAT-ом в нашей локальной сети. Будь то веб-сервер или персоналка, к которой надо дать доступ снаружи по протоколу RDP, чтобы сотрудник мог работать из дома используя «Удаленный рабочий стол». Сегодня расскажу, как пробросить порты на роутере MikroTik используя dst-nat.

В статье, посвященной настройке DHCP-сервера, я раздал IP-адреса двум компьютерам: 192.168.33.2 и 192.168.33.129. Пусть первый будет веб-сервером, а второй будет персоналкой. Соответственно, для веб-сервера нам нужно пробросить, как минимум 80-ый порт, а для персоналки — порты для удовлетворения хотелок пользователя. А пользователь хочет удаленный рабочий стол. Пусть нашим внешним ip будет 1.1.1.1 на интерфейсе inetTest.

Проброс портов в winbox

Открываем IP — Firewall — NAT, жмем «+»

Добавление правила NAT

Chain — цепочка, в которой будет обрабатываться правило. Выбираем dstnat.
Src. Address — адрес источника. Если мы хотим указать конкретный адрес, то забиваем сюда. Но т.к. веб-сервер должен быть доступен всем, то я это поле не заполняю.
Dst. Address — адрес, к которому будут обращаться клиенты извне. В данном примере это адрес 1.1.1.1. Можно этот адрес не указывать, но в этом случае нужно будет обязательно указать In. Interface
Protocol — выбираем TCP.
Dst. port — порт, к которому будут обращаться клиенты извне. Для веб-сервера по-умолчанию это порт 80.
In. Interface — интерфейс, который смотрит наружу. В нашем случае это интерфейс inetTest.

Остальные параметры нам в этой статье неинтересны, поэтому переходим на вкладку Action.

Добавление правила вкладка Action

Action — выбираем dst-nat.
To Addresses — пишем IP-адрес нашего веб-сервера в локальной сети.
To Ports — порт 80.

Этого, собственно, достаточно. Но есть один очень важный момент. У роутера MikroTik есть встроенный веб-сервер, который висит на том же дефолтном порту 80. Надо его оттуда убрать. Заходим в IP — Services и меняем там порт службы www с 80-го, на произвольный.

Процесс создания правила проброса порта RDP для персоналки аналогичен вышеописанному.

Проброс портов — скрипты

В скриптах я добавил еще одно правило для протокола HTTPS на веб-сервер, а для проброса RDP использовал нестандартный порт.

Источник

Mikrotik пробросить 443 порт

Sun Mar 22, 2015 12:59 pm

please help me to setup incoming forwarding rule for 443 ports.
I have to froward incoming traffic on port 443 (SSL — browser) to other device than my router.

router-wan(internet source)=192.168.40.1
router-lan=192.168.50.1
ssl-device(forward ssl to)=192.168.50.2

I tried to make it by my selves:

ip firewall nat add chain=dstnat action=dst-nat to-addresses=192.168.50.2 to-ports=443 protocol=tcp dst-port=443

but after this all my outgoing traffic on port 443 does not work.

My chrome browser gives me message «NET::ERR_CERT_COMMON_NAME_INVALID»

Subject: http://www.opennas.pl
Issuer: StartCom Class 1 Primary Intermediate Server CA
Expires on: 26 paź 2015
Current date: 22 mar 2015
PEM encoded chain: ——BEGIN CERTIFICATE——
MIIGNzCCBR+gAwIBAgIDE9UqMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYDVQQGEwJJ
.

It looks that after forwarding 443 port my browser also outgoing trafic gets my ssh cert connected to my domain opennas.pl

How to NAT my incoming traffic on port 443 and not block my outgoing traffic on port 443

Re: Incoming traffic forwarding on 443 port

Sun Mar 22, 2015 3:11 pm

Currently you’re telling the router to take all traffic to port 443, going to *any* address and forward it to your device. And that’s exactly what you’re getting. You need to be more selective, some options are:

a) dst-address=192.168.40.1
b) in-interface=
c) dst-address-type=local

Re: Incoming traffic forwarding on 443 port

Sun Mar 22, 2015 4:12 pm

Re: Incoming traffic forwarding on 443 port

Sun Mar 22, 2015 6:24 pm

You should only need one of those 3 options.
I’ve always used suggestion b, personally.

If your rule reads like this, then it should work w/o breaking outbound SSL:
/ip firewall nat
add chain=dstnat action=dst-nat to-addresses=192.168.50.2 protocol=tcp dst-port=443 in-interface=WAN

If this rule isn’t working, make sure of the following:
no other rule in the dstnat chain is matching packets before they reach this rule.
no filter rule in your forward chain is blocking the transaction
— and the silly things you never think about because they’re «never» why it’s not working:
server is working
server is reachable from Mikrotik (ping works, correct MAC address in arp table)
server has correct IP/netmask/default gw settings.

Re: Incoming traffic forwarding on 443 port

Mon Mar 23, 2015 6:11 pm

router-wan(internet source)=192.168.1.101
router-lan=192.168.2.254
ssl-device(forward ssl to)=192.168.2.2

The solution works but that depends from where I’m checking the whole solution.

1. OUTSIDE LAN — INTERNET

When I’m trying to check from outside to domain mydomain.com (195.123.33.44)

ip firewall nat add chain=dstnat action=dst-nat to-addresses=192.168.2.2 to-ports=443
protocol=tcp dst-address=192.168.1.101 dst-port=443 in-interface=ether1-gateway

From Outside works fine, but when I’m checking from my LAN 192.168.2.1 server (192.168.2.2) is unrechable.

When I change dst-address to my external IP dst-address=195.123.33.44 domain mydomain.com (195.123.33.44)
server is reachable from inside LAN (192.168.2.1) but is not reachable from outside.

ip firewall nat add chain=dstnat action=dst-nat to-addresses=192.168.2.2 to-ports=443
protocol=tcp dst-address=195.123.33.44 dst-port=443 in-interface=ether1-gateway

Please help me to find solution for this rule to be accessible from outside and inside LAN.

Re: Incoming traffic forwarding on 443 port

Mon Mar 23, 2015 7:02 pm

Note that when doing this, the internal host cannot see the src IP for internal connections — they will all appear to come from the Mikrotik. (you have to do this for NAT hairpin)

A cleaner solution would be to implement DNS proxy on the Mikrotik.
Either explicitly configure it as the DNS server for your LAN, or else make a redirect rule for udp/53 on the LAN side.
Then create a static DNS host entry for mydomain.com -> 192.168.2.2

Your internal hosts will need to use the hostname to reach the server, but that’s normal, and sounds like what you want to do anyway. Doing it this way will allow the logs on the web server to show the actual source IP in all cases, and not just external hosts.

Finally, I would try to get the ISP to put their device in bridge mode and have the public IP directly on the Mikrotik. Being behind double NAT can cause problems with some applications, and requires you to coordinate with the ISP every time you add some new service (unless they just 1:1 all ports to your Mikrotik)

Re: Incoming traffic forwarding on 443 port

Mon Mar 23, 2015 7:40 pm

Thank’s for your solution.

this works same

From outside LAN (internet) is ok, but this is not working from inside LAN (192.168.2.1).

Probably this is only one choice using NAT? but I still wondering why this common sitiation to publish 443 port causes such a problem ?

So I just wondering how may I implement DNS proxy on the Mikrotik?

Re: Incoming traffic forwarding on 443 port

Mon Mar 23, 2015 8:27 pm

From outside LAN (internet) is ok, but this is not working from inside LAN (192.168.2.1).

Probably this is only one choice using NAT? but I still wondering why this common sitiation to publish 443 port causes such a problem ?

So I just wondering how may I implement DNS proxy on the Mikrotik?

Notice that there is a source NAT rule added for LAN<>LAN communications.

add action=masquerade chain=srcnat dst-address=192.168.2.0/24 out-interface=LAN src-address=192.168.2.0/24

I tested my rules on a lab and they work for LAN->LAN and for WAN->LAN.
It also does not incorrectly redirect 443 for LAN->WAN — these continue to go out correctly to the Internet.

However, DNS proxy is pretty easy.

In Winbox, under IP > DNS, make sure there are servers defined (or dynamic servers learned from your WAN connection). As long as the Mikrotik itself can successfully make DNS lookups, make sure the «Allow Remote Requests» checkbox is checked.

In the same screen, click the Static button, then the + to add a new entry.
Be sure to include an entry for every name that clients can use to reach the server.
mydomain.com
http://www.mydomain.com
myotherdomain.com
http://www.myotherdomain.com
etc.

Finally, assign the Mikrotik’s LAN IP as the DNS server in your internal DHCP (IP > DHCP-Server > Networks > 192.168.2.0/24 > DNS Servers: 192.168.2.1
Optionally, you can create a redirect rule in dstnat chain (port 53, udp and tcp) — action=redirect means to intercept the request and handle it with the Mikrotik itself. Interestingly, after doing this — every IP address on the Internet will work as DNS for your client PCs.

FYI — the reason the srcnat is required is this:

request from 192.168.2.99:12345 -> 192.168.1.101:443
-DSTNAT-
packet is now 192.168.2.99:12345 -> 192.168.2.2:443
-packet forwards to server-
-Server sees source is local IP — sends reply directly to client-
-client receives packet directly from server, Mikrotik is skipped-
packet = 192.168.2.2:443 -> 192.168.2.99:12345
-client is confused — it never asked for 192.168.2.99:443 so it drops the packet-
-client never receives reply from 192.168.1.101:443, and sends a re-try-
-retry fails for same reason-
-max retries, connection times out-

Re: Incoming traffic forwarding on 443 port

Tue Mar 24, 2015 5:09 am

Just a few notes.

because packets coming from ether1-gateway interface won’t ever have 195.123.33.44 as their destination. Packets from outside going to 195.123.33.44 get forwarded by first router to your WAN address 192.168.1.101 and that’s their new destination address.

ZeroByte’s hairpin rules are basically correct, but not exactly in this case (sorry ). If LAN client tries to connect to 195.123.33.44, it goes straight through your router to first one, which actually has 195.123.33.44. And if that router does hairpin NAT, it will send the packet back to your router with source address different from original 192.168.1.101 and you do not have to do anything special, because it will look as regular external connection. You would not need this rule:

The problem here seems to be that the first router does not do hairpin NAT, so it just bounces packet back with original source address 192.168.1.101, your router does not expect it and drops it.

If you wanted it to work from both inside and outside, you’d have to intercept outgoing packets to 195.123.33.44 and redirect them back to server on your router. This should work:

First dst-nat is for packets from outside, second for packets from inside.

Long story short, NAT sucks and double NAT sucks more. Using DNS is probably better in your case.

Источник