/ip firewall nat
add chain=dstnat dst-address=<public IP> protocol=tcp dst-port=80,443 action=dst-nat to-adresses=192.168.100.x
/ip firewall filter
add action=accept chain=forward connection-nat-state=dstnat
Stated in his initial post that it doesn't work on his network.If you mean the srcnat rule with same src/dst-address=<LAN subnet>/<mask> used with hairpin NAT, that's not needed here. It's needed when client thinks that it communicates with some external address, but server would see client's real address from same subnet, would reply directly and that would not work, because client expects reply from that external address. But in this case, even if server sees client's real address, the reply will still be sent to router, because the address is in another subnet. And it will work.
export hide-sensitive
# mar/12/2019 13:48:21 by RouterOS 6.44
# software id = XXX
#
# model = RB760iGS
# serial number = XXX
/interface ethernet
set [ find default-name=ether2 ] disabled=yes
set [ find default-name=sfp1 ] disabled=yes
/interface vlan
add interface=ether3 name=vlan10 vlan-id=10
add interface=ether3 name=vlan20 vlan-id=20
/interface list
add name=WAN
add name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/ip pool
add name=dhcp ranges=192.168.0.10-192.168.0.40
add name=dhcp_pool6 ranges=192.168.20.2-192.168.20.254
add name=dhcp_pool10 ranges=192.168.10.2-192.168.10.254
add name=DMZ ranges=192.168.100.2-192.168.100.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=ether5 lease-time=2h name=server1
add address-pool=dhcp_pool6 disabled=no interface=vlan20 name=dhcp2
add address-pool=DMZ disabled=no interface=ether4 name=dhcp3
add address-pool=dhcp_pool10 disabled=no interface=vlan10 name=dhcp4
/dude
set enabled=yes
/interface list member
add interface=ether1 list=WAN
add interface=ether5 list=LAN
/ip address
add address=192.168.0.1/24 interface=ether5 network=192.168.0.0
add address=192.168.20.1/24 interface=vlan20 network=192.168.20.0
add address=192.168.10.1/24 interface=vlan10 network=192.168.10.0
add address=192.168.100.1/24 interface=ether4 network=192.168.100.0
add address=XXX/30 interface=ether1 network=YYY
/ip dhcp-server lease
add address=192.168.0.136 allow-dual-stack-queue=no disabled=yes mac-address=00:00:00:00:00:00 server=server1
add address=192.168.0.113 allow-dual-stack-queue=no mac-address=00:00:00:00:00:00 server=server1
add address=192.168.0.26 client-id=00:00:00:00:00:00 mac-address=00:00:00:00:00:00 server=server1
/ip dhcp-server network
add address=192.168.0.0/24 dns-server=192.168.0.113,192.168.0.3 gateway=192.168.0.1 netmask=24
add address=192.168.10.0/24 dns-server=192.168.10.1 gateway=192.168.10.1
add address=192.168.20.0/24 dns-server=192.168.20.1 gateway=192.168.20.1 netmask=24
add address=192.168.100.0/24 dns-server=192.168.100.1 gateway=192.168.100.1 netmask=24
/ip dns
set allow-remote-requests=yes servers=1.1.1.1,1.0.0.1
/ip dns static
add address=192.168.100.110 name=test.com
/ip firewall filter
add action=accept chain=forward connection-nat-state=dstnat
add action=accept chain=forward dst-address=192.168.0.0/24 dst-port=80,443 protocol=tcp src-address=192.168.100.110 src-port=80,443
add action=accept chain=forward dst-address=192.168.100.110 dst-port=80,443 protocol=tcp src-address=192.168.0.0/24 src-port=80,443
add action=drop chain=forward dst-address=192.168.100.0/24 src-address=192.168.0.0/24
add action=drop chain=forward dst-address=192.168.20.0/24 src-address=192.168.0.0/24
add action=drop chain=forward dst-address=192.168.0.0/24 src-address=192.168.100.0/24
add action=drop chain=forward dst-address=192.168.0.0/24 src-address=192.168.20.0/24
add action=drop chain=input comment="drop ssh from wan" connection-state=related dst-port=22 log=yes protocol=tcp
add action=drop chain=input comment="drop winbox from wan" dst-port=8291 in-interface-list=WAN log=yes protocol=tcp
/ip firewall nat
add action=masquerade chain=srcnat out-interface-list=WAN
add action=dst-nat chain=dstnat comment="HTTPS an reverse proxy" dst-address=XXX dst-port=80,443 in-interface=ether1 \
protocol=tcp to-addresses=192.168.100.110 to-ports=443
add action=dst-nat chain=dstnat dst-address=XXX dst-port=8444 in-interface=ether1 protocol=tcp to-addresses=192.168.100.110 \
to-ports=443
add action=dst-nat chain=dstnat comment="HTTP an reverse proxy" disabled=yes dst-address=XXX dst-port=80 in-interface=ether1 \
protocol=tcp to-addresses=192.168.100.110 to-ports=80
add action=dst-nat chain=dstnat dst-address=XXX dst-port=50000 in-interface=ether1 protocol=tcp to-addresses=192.168.100.52 \
to-ports=50000
add action=dst-nat chain=dstnat dst-address=XXX dst-port=1194 in-interface=ether1 protocol=udp to-addresses=192.168.0.113 \
to-ports=1194
add action=dst-nat chain=dstnat dst-address=XXX dst-port=1195 in-interface=ether1 protocol=udp to-addresses=192.168.0.250 \
to-ports=1195
add action=dst-nat chain=dstnat disabled=yes dst-address=192.168.0.11 dst-port=32400 in-interface=ether1 protocol=tcp to-addresses=\
192.168.0.117 to-ports=26065
add action=dst-nat chain=dstnat comment="192.168.0.117: Plex Media Server" dst-address=XXX dst-port=26065 in-interface=ether1 \
protocol=tcp to-addresses=192.168.0.117 to-ports=32400
add action=dst-nat chain=dstnat comment="192.168.0.117: Plex Media Server" dst-address=XXX dst-port=26070 in-interface=ether1 \
protocol=tcp to-addresses=192.168.0.136 to-ports=32400
add action=masquerade chain=srcnat disabled=yes dst-address=XXX dst-port=443 out-interface=ether4 protocol=tcp src-address=\
192.168.0.0/24
/ip firewall service-port
set ftp disabled=yes
/ip ipsec policy
set 0 disabled=yes
/ip route
add distance=1 gateway=YYY
/ip service
set telnet address=192.168.0.0/24 disabled=yes
set ftp address=192.168.0.0/24 disabled=yes
set www address=192.168.0.0/24
set ssh address=192.168.0.0/24
set api address=192.168.0.0/24 disabled=yes
set winbox address=192.168.0.0/24
set api-ssl address=192.168.0.0/24 disabled=yes
/ip ssh
set allow-none-crypto=yes
/ip upnp
set allow-disable-external-interface=yes
/ip upnp interfaces
add type=internal
add interface=ether1 type=external
/snmp
set enabled=yes trap-generators=""
/system clock
set time-zone-name=Europe/Berlin
/tool bandwidth-server
set enabled=no
/tool graphing interface
add interface=ether1
add interface=ether5
add interface=ether2
add interface=ether3
add interface=ether4
add interface=vlan20
add interface=vlan10
/tool mac-server ping
set enabled=no
Okay so if this is all true, and not some sad sob story LOL, then shouldn't the rule include a source address list for added security??Gotta use the EXTERNAL IP... interface won't do it.
Like SOB put it...
/ip firewall nat
add chain=dstnat dst-address=<public IP> protocol=tcp dst-port=80,443 action=dst-nat to-adresses=192.168.100.x
PUBLIC IP.
/ip firewall filter
add action=accept chain=forward dst-address=192.168.0.0/24 dst-port=80,443 protocol=tcp src-address=192.168.100.110 src-port=80,443
add action=accept chain=forward dst-address=192.168.100.110 dst-port=80,443 protocol=tcp src-address=192.168.0.0/24 src-port=80,443
/ip firewall filter
add action=accept chain=forward connection-nat-state=dstnat
/interface list
add name=WAN
add name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip pool
add name=dhcp ranges=192.168.0.10-192.168.0.40
add name=dhcp_pool6 ranges=192.168.20.2-192.168.20.254
add name=dhcp_pool10 ranges=192.168.10.2-192.168.10.254
add name=DMZ ranges=192.168.100.2-192.168.100.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=ether5 lease-time=2h name=server1
add address-pool=dhcp_pool6 disabled=no interface=vlan20 name=dhcp2
add address-pool=DMZ disabled=no interface=ether4 name=dhcp3
add address-pool=dhcp_pool10 disabled=no interface=vlan10 name=dhcp4
/interface list member
add interface=ether1 list=WAN
add interface=ether5 list=LAN
/ip address
add address=192.168.0.1/24 interface=ether5 network=192.168.0.0
add address=192.168.20.1/24 interface=vlan20 network=192.168.20.0
add address=192.168.10.1/24 interface=vlan10 network=192.168.10.0
add address=192.168.100.1/24 interface=ether4 network=192.168.100.0
add address=EXTERNAL IP/30 interface=ether1 network=AAA
/ip dhcp-server lease
/ip dns
set allow-remote-requests=yes servers=1.1.1.1,1.0.0.1
/ip dns static
add address=192.168.100.110 name=domainA
add address=192.168.100.110 name=domainB
add address=192.168.100.110 name=domainC
/ip firewall filter
add action=accept chain=forward connection-nat-state=dstnat
add action=drop chain=forward dst-address=192.168.100.0/24 src-address=192.168.0.0/24
add action=drop chain=forward dst-address=192.168.0.0/24 src-address=192.168.100.0/24
add action=drop chain=forward dst-address=192.168.20.0/24 src-address=192.168.0.0/24
add action=drop chain=forward dst-address=192.168.0.0/24 src-address=192.168.20.0/24
add action=drop chain=input comment="drop ssh from wan" connection-state=related dst-port=22 log=yes protocol=tcp
add action=drop chain=input comment="drop winbox from wan" dst-port=8291 in-interface-list=WAN log=yes protocol=tcp
/ip firewall nat
add action=masquerade chain=srcnat out-interface-list=WAN
add action=dst-nat chain=dstnat comment="HTTPS an reverse proxy" dst-address=EXTERNAL IP dst-port=80,443 protocol=tcp to-addresses=\
192.168.100.110
add action=dst-nat chain=dstnat dst-address=EXTERNAL IP dst-port=1194 in-interface=ether1 protocol=udp to-addresses=192.168.0.113 \
to-ports=1194
add action=dst-nat chain=dstnat comment="192.168.0.117: Plex Media Server" dst-address=EXTERNAL IP dst-port=26070 in-interface=ether1 \
protocol=tcp to-addresses=192.168.0.136 to-ports=32400
/ip ipsec policy
set 0 disabled=yes
/ip route
add distance=1 gateway=YYY
/ip firewall filter
add action=accept chain=forward connection-state=established,related,untracked
add action=drop chain=forward connection-state=invalid
add action=drop chain=forward connection-nat-state=!dstnat in-interface-list=WAN
add action=drop chain=forward dst-address=192.168.100.0/24 src-address=192.168.0.0/24
add action=drop chain=forward dst-address=192.168.0.0/24 src-address=192.168.100.0/24
add action=drop chain=forward dst-address=192.168.20.0/24 src-address=192.168.0.0/24
add action=drop chain=forward dst-address=192.168.0.0/24 src-address=192.168.20.0/24
/ip firewall filter
add action=accept chain=forward connection-state=established,related,untracked
add action=drop chain=forward connection-state=invalid
add action=accept chain=forward connection-nat-state=dstnat comment="allow forwarded ports"
add action=accept chain=forward in-interface-list=!WAN out-interface-list=WAN comment="all LANs can access internet"
add action=accept chain=forward src-address=192.168.0.0/24 dst-address=192.168.10.0/24
add action=accept chain=forward src-address=192.168.20.0/24 dst-address=!192.168.0.0/24
add action=accept chain=forward src-address=192.168.10.0/24
add action=accept chain=forward src-address=192.168.100.0/24 dst-address=!192.168.0.0/24
add action=log chain=forward log-prefix="BLOCK" comment="log what will be blocked"
add action=reject chain=forward reject-with=icmp-admin-prohibited disabled=yes comment="block it for real; only enable when you're sure that you allowed everything you need"
add action=accept in-interface=ether5 src-address=192.168.0.0/24 out-interface-list=WAN
add action=accept in-interface=vlan20 src-address=192.168.20.0/24 out-interface-list=WAN
...
/ip firewall filter
add action=accept chain=forward connection-nat-state=dstnat
add action=drop chain=input connection-state=invalid
add action=accept chain=input comment="Allow Established connections" connection-state=established
add action=accept chain=input comment="Allow ICMP" protocol=icmp
add action=drop chain=forward comment="drop invalid connections" connection-state=invalid protocol=tcp
add action=accept chain=forward comment="allow already established connections" connection-state=established
add action=accept chain=forward comment="allow related connections" connection-state=related
add action=accept chain=forward comment="Allow traffic between Workstation and Webserver" dst-address=192.168.100.110 dst-port=443,80 \
protocol=tcp src-address=192.168.0.33
add action=accept chain=forward comment="Allow traffic between Workstation and Webserver" dst-address=192.168.0.33 protocol=tcp \
src-address=192.168.100.110 src-port=443,80
add action=drop chain=forward comment="Block traffic between these subnets" dst-address=192.168.100.0/24 src-address=192.168.0.0/24
add action=drop chain=forward comment="Block traffic between these subnets" dst-address=192.168.0.0/24 src-address=192.168.100.0/24
add action=drop chain=forward comment="Block traffic between these subnets" dst-address=192.168.20.0/24 src-address=192.168.0.0/24
add action=drop chain=forward comment="Block traffic between these subnets" dst-address=192.168.0.0/24 src-address=192.168.20.0/24
add action=drop chain=input comment="drop ssh from wan" connection-state=related in-interface-list=WAN log=yes
add action=drop chain=input comment="drop winbox from wan" dst-port=8291 in-interface-list=WAN log=yes protocol=tcp
add action=drop chain=forward comment="Block Fressebuch" layer7-protocol="Block Site" src-address=192.168.0.0/24
add action=drop chain=forward in-interface=ether4 src-address-list=192.168.100.0/24
add action=drop chain=input comment="Block Russian, Chinese and Vietnam IPs" log=yes src-address-list=CountryIPBlocks
add action=drop chain=forward src-address=0.0.0.0/8
add action=drop chain=forward dst-address=0.0.0.0/8
add action=drop chain=forward src-address=127.0.0.0/8
add action=drop chain=forward dst-address=127.0.0.0/8
add action=drop chain=forward src-address=224.0.0.0/3
add action=drop chain=forward dst-address=224.0.0.0/3
add action=jump chain=forward jump-target=tcp protocol=tcp
add action=jump chain=forward jump-target=udp protocol=udp
add action=jump chain=forward jump-target=icmp protocol=icmp
add action=accept chain=input dst-port=161 protocol=udp
add action=drop chain=input comment="Block everything else"
I don't know why people always use in-interface for port forwarding, it will bite them sooner or later.![]()
They could make an address list entry using the IP Cloud address.I don't know why people always use in-interface for port forwarding, it will bite them sooner or later.![]()
Because they saw it in some youtube tutorial, which was made on basis of having dynamic WAN address (e.g. PPPoE or DHCP) ... and if that's so, one can not really use dst-address as dst-nat criteria.
See the first paragraph of my previous reply.I had to allow ports 443 and 80 between my client and the reverse proxy.
/ip firewall filter
add action=drop chain=forward connection-nat-state=!dstnat in-interface-list=WAN
/ip firewall filter
add chain=input protocol=udp dst-port=53 in-interface-list=!WAN
add chain=input protocol=tcp dst-port=53 in-interface-list=!WAN
There's also "dst-address-type=local dst-address=!<router's LAN address>". It's not perfect, because it can match other addresses where it's not desired (e.g. address that VPN client gets from server). And even if it can be solved using other rules, it would not longer be an elegant solution. But the main evil here is dynamic address for server.They could make an address list entry using the IP Cloud address.
/ip firewall nat
add chain=dstnat dst-address=1.2.3.4 protocol=tcp dst-port=80 action=dst-nat to-addresses=192.168.88.10
In the config you posted, input chain was this:But why don't I allow any winbox connection anymore? I reopened it a few times in the last hours?
/ip firewall filter
add action=drop chain=input connection-state=invalid
add action=accept chain=input comment="Allow Established connections" connection-state=established
add action=accept chain=input comment="Allow ICMP" protocol=icmp
add action=drop chain=input comment="drop ssh from wan" connection-state=related in-interface-list=WAN log=yes
add action=drop chain=input comment="drop winbox from wan" dst-port=8291 in-interface-list=WAN log=yes protocol=tcp
add action=drop chain=input comment="Block Russian, Chinese and Vietnam IPs" log=yes src-address-list=CountryIPBlocks
add action=accept chain=input dst-port=161 protocol=udp
add action=drop chain=input comment="Block everything else"
The client receives the reply packet, but it discards it because it expects a packet back from 1.1.1.1, and not from 192.168.1.2. As far as the client is concerned the packet is invalid and not related to any connection the client previously attempted to establish.
- the client sends a packet with a source IP address of 192.168.1.10 to a destination IP address of 1.1.1.1 on port tcp/80 to request some web resource.
- the router destination NATs the packet to 192.168.1.2 and replaces the destination IP address in the packet accordingly. The source IP address stays the same: 192.168.1.10.
- the server replies to the client's request. However, the source IP address of the request is on the same subnet as the web server. The web server does not send the reply back to the router, but sends it back directly to 192.168.1.10 with a source IP address in the reply of 192.168.1.2.
Aha Eureka LOL!!All the effort that MikroTik put into writing the hairpin NAT article, explaining things in detail, ...
Ok, I'll copy the important part for you:The client receives the reply packet, but it discards it because it expects a packet back from 1.1.1.1, and not from 192.168.1.2. As far as the client is concerned the packet is invalid and not related to any connection the client previously attempted to establish.
- the client sends a packet with a source IP address of 192.168.1.10 to a destination IP address of 1.1.1.1 on port tcp/80 to request some web resource.
- the router destination NATs the packet to 192.168.1.2 and replaces the destination IP address in the packet accordingly. The source IP address stays the same: 192.168.1.10.
- the server replies to the client's request. However, the source IP address of the request is on the same subnet as the web server. The web server does not send the reply back to the router, but sends it back directly to 192.168.1.10 with a source IP address in the reply of 192.168.1.2.
So the reason the server sends it directly back to the originator is because it uses layer 2 connectivity first???
If the source is in a different subnet there is no layer2 window of opportunity!!