Firewall NAT trouble

Hi, i have a ccr1016 v7.20.1 and i’ trying really hard to configure the nat rules.

My scenario:

-modem from the provider (italian tim) for internet connection ip 192.168.80.1 on eth1

-subnet 192.168.79.0/24 for domestic lan

-subnet 192.168.64.0/24 for ‘job devices’

My goals:

-internet connection from the isp router for 64 and 79 devices (it works)

-dhcp for both lan (it works)

-firewall rules for external access to the devices (it doesn’ t work)

Here my ccr config

# 2026-01-03 23:00:31 by RouterOS 7.20.1
# software id = F9QA-XB8P
#
# model = CCR1016-12G
# serial number = 42D4xxxx
/interface bridge
add name=dax_bridge
add name=sovicom_bridge
/interface ethernet
set [ find default-name=ether1 ] name=eth1_TIM
set [ find default-name=ether2 ] name=eth2_PC
set [ find default-name=ether3 ] name=eth3_Samsung
set [ find default-name=ether4 ] name=eth4_Ubiquiti
set [ find default-name=ether5 ] name=eth5_Server
set [ find default-name=ether6 ] name=eth6_Camera1
set [ find default-name=ether7 ] name=eth7_Camera2
set [ find default-name=ether8 ] name=eth8_Camera3
set [ find default-name=ether9 ] name=eth9_Cameretta1
set [ find default-name=ether10 ] name=eth10_Cameretta2
set [ find default-name=ether11 ] name=eth11_Ingresso
set [ find default-name=ether12 ] name=eth12_RB433
/ip pool
add name=dax_pool79 ranges=192.168.79.201-192.168.79.254
add name=sovicom_pool64 ranges=192.168.64.11-192.168.64.15
/ip dhcp-server
add address-pool=dax_pool79 interface=dax_bridge name=dhcp79
add address-pool=sovicom_pool64 interface=sovicom_bridge name=dhcp64
/port
set 0 name=serial0
set 1 name=serial1
/interface bridge port
add bridge=dax_bridge interface=eth2_PC
add bridge=sovicom_bridge interface=eth4_Ubiquiti
add bridge=dax_bridge interface=eth3_Samsung
add bridge=dax_bridge interface=eth5_Server
add bridge=dax_bridge interface=eth6_Camera1
add bridge=dax_bridge interface=eth7_Camera2
add bridge=dax_bridge interface=eth8_Camera3
add bridge=dax_bridge interface=eth9_Cameretta1
add bridge=dax_bridge interface=eth10_Cameretta2
add bridge=dax_bridge interface=eth11_Ingresso
add bridge=sovicom_bridge interface=eth12_RB433
/ip neighbor discovery-settings
set discover-interface-list=!dynamic
/ip address
add address=192.168.79.2/24 interface=dax_bridge network=192.168.79.0
add address=192.168.64.2/24 interface=sovicom_bridge network=192.168.64.0
add address=192.168.80.2/24 interface=eth1_TIM network=192.168.80.0
/ip dhcp-server lease
add address=192.168.79.10 comment="PC Dax" mac-address=F4:6D:xxxxx
add address=192.168.79.20 comment=Samsung mac-address=0C:89:xxxxx
add address=192.168.79.30 comment="TIM Box" mac-address=7C:16:xxxxxx
add address=192.168.79.50 comment="Server Sovicom" mac-address=\
    00:19:99:xxxx
/ip dhcp-server network
add address=192.168.64.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=192.168.64.2
add address=192.168.79.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=192.168.79.2
/ip dns
set servers=8.8.8.8,8.8.4.4
/ip firewall nat
add action=masquerade chain=srcnat comment="Internet TIM" out-interface=\
    eth1_TIM
add action=masquerade chain=srcnat comment=6X_sovicom out-interface=\
    sovicom_bridge
add action=dst-nat chain=dstnat comment=DAB dst-port=23455 protocol=tcp \
    to-addresses=192.168.64.100 to-ports=80
add action=dst-nat chain=dstnat comment="Sovicom Server SSH" dst-port=23456 \
    protocol=tcp to-addresses=192.168.79.50 to-ports=23456
/ip route
add comment=TIM disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.80.1 pref-src="" routing-table=main scope=30 suppress-hw-offload=\
    no target-scope=10
/system clock
set time-zone-name=Europe/Rome
/system identity
set name=CCR1016_Sovicom
/system ntp client
set enabled=yes
/system ntp client servers
add address=193.204.114.232
add address=pool.ntp.org

If i access to my ftp server through ssh on lan i see that the ip is 192.168.79.50/24 gw 192.168.79.2 and dns 8.8.8.8;8.8.4.4 and i can ping google.it

But if i try to connect from outside on port 23456 i get connection aborted . Same situation on port 23455 for other device. The dns is updated of course

Where i’m wrong? I’m not skilled so please be patient :grinning_face:

Thanks a lot

Davide

So you do not have a public IP (your IP is 192.168.80.2 which is local according to RFC1918), do you? From where do you want to connect to 23455?

Also, I do not see any forward rule: do you really have no firewall configured (i.e everything is open)?

Sorry, 192.168.80.1 is the lan ip of the provider modem and it is connected to eth1 on ccr with 192.168.80.2 ip address. I get the dynamic public ip address from the modem.

From my smartphone, or also from a pc outside of my net.

I post the full configuration.

Which IP do you use to connect? Do you use your dynamic public IP? This this case, you should configure port-forwarding on your modem because it implements source NAT for you. Or you should get dynamic IP directly on your router (it might or may not be possible depending on your ISP, some modems provide “bridge mode” to achieve it).

But don't even think of putting the ISP modem router in bridge mode without first setting up some proper firewall rules on the Mikrotik device.

1 Like

Yes, mydyndns:23455

Ok, maybe i cant try to put a fritz 7530 with openwrt in bridge mode instead of a modem from the provider

Uhm… Where i can find/read the proper firewall rules?

Unfortunately the CCR devices do not come with a default firewall as they are mainly targeting ISP/Corporate use, not consumer NAT routing.

You could consider using the default firewall of home devices:

     /interface list add name=WAN comment="defconf"                                                                                                              
     /interface list add name=LAN comment="defconf"     
     /interface list member add list=LAN interface=bridge comment="defconf"                                                                                      
     /interface list member add list=WAN interface=ether1 comment="defconf"     
     /ip firewall {                                                                                                                                              
       filter add chain=input action=accept connection-state=established,related,untracked comment="defconf: accept established,related,untracked"               
       filter add chain=input action=drop connection-state=invalid comment="defconf: drop invalid"                                                               
       filter add chain=input action=accept protocol=icmp comment="defconf: accept ICMP"                                                                         
       filter add chain=input action=accept dst-address=127.0.0.1 comment="defconf: accept to local loopback (for CAPsMAN)"                                      
       filter add chain=input action=drop in-interface-list=!LAN comment="defconf: drop all not coming from LAN"                                                 
       filter add chain=forward action=accept ipsec-policy=in,ipsec comment="defconf: accept in ipsec policy"                                                    
       filter add chain=forward action=accept ipsec-policy=out,ipsec comment="defconf: accept out ipsec policy"                                                  
       filter add chain=forward action=fasttrack-connection connection-state=established,related comment="defconf: fasttrack"                                    
       filter add chain=forward action=accept connection-state=established,related,untracked comment="defconf: accept established,related, untracked"            
       filter add chain=forward action=drop connection-state=invalid comment="defconf: drop invalid"                                                             
       filter add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="defconf: drop all from WAN not DSTNATed"
     }                                                                          

In this firewall, ether1 is assumed to be the WAN interface and “bridge” is the LAN interface, but you can change the interface list memberships as required.

@dax79
Since you are new to Mikrotik devices, you should have a look at the (unofficial) Rules:

particularly #8.

AFAICR TIM (italian Telecom) provides routers which can rarely be set to bridge mode, so the idea of using another device with OpenWRT is probably the best one, but the ISP provided modem/router should be able to forward some ports[1].

If you have available a Fritzbox 7530 running OpenWRT, maybe you could still set it up as "main" router (with its own firewall), I have no idea how fast is the 7530 (nor which kind of speed your connection has), but loosely having two routers one after the another (i.e. double NAT) is not as bad as many people believe, the only sometimes noticeable issue - in some cases - can be an increase in latency, that may only affect gaming.

AFAICR in OpenWRT jargon what on Mikrotiks is called hairpin NAT is usually called NAT loopback, if you want to search info on that.

[1] Usually related info/discussions can be found on:
https://forum.fibra.click/

Thanks a lot!

Yes, i have a 7530 running openwrt. My connection speed is 100/20 Mb.

Could be an option a totally firewall disable on openwrt? I mean the 7530 a main router for internet connection without a firewall and the port forwarding managed by ccr?

I known, i’m not in openwrt forum :grinning_face:

Yes, you can set the Fritzbox as bridge (no NAT, no Firewall) as Ilka suggested, so it will become a "media converter" and use the CCR as "edge router" (and firewall).
Since the firewall will be on the CCR, you should never connect any other device directly to the Fritzbox, only the CCR should be connected to it.

Due to house wiring it will be a problem…

Sorry if i wasn’ t clear, it’ s due to my lacking knowledge. Is it possible to use fritz as ‘normal’ (also as access poitn and with other lan port) modem without nat and firewall?

It is possible to run 2 IP ranges on the network, e.g. 192.168.178.1/24 for the Fritzbox and 192.168.88.1/24 for the MikroTik LAN (both defaults). When you disable the DHCP server of the Fritzbox and put all ports in the MikroTik in the same bridge, with the MikroTik on a static IP like 192.168.178.2/24 with default route via 192.168.178.1 and configure the DHCP server on the MikroTik, the clients will not notice this (unless they want to) and you can use the FritzBox WiFi interface as usual.

The generic point is that the (fiber or cable) connection from your ISP can (please read as WILL) allow anyone on the internet to get inside your house, so the FIRST device connected to it MUST have a working firewall to prevent intrusions.

If the firewall is on the second device, there must be ONLY a connection between it and the first one, and ALL clients must be connected "downstream" from this second device.

If the Fritzbox is your first device, and you plan to use it as access point or however connect to it other devices, it MUST run a firewall.

I don't want to scare you, but - just as an example - a Mikrotik router connected to the internet with default user "admin" and blank password (or a common one) will survive a handful of seconds, maybe a few minutes, before being pwned, see:

There is no reason to believe that any other device on your network, if accessible from the internet, is safe from these bots.

So, whatever topology/approach you choose, ALL clients should be behind a firewall, one way or the other.

In practice it will not be that bad, because when you have a provider modem in bridge mode, and you have only a single IP from the provider (as usual), there will be some setup in bridge mode like the MAC address of the next hop (maybe auto-determined from a “local network devices” GUI thing) and when that points to the MikroTik router as second device and it has the proper firewall, there is no way for outside perpetrators to directly access other devices even when they are on the same physical network.

(which is necessary to re-use the other features of the device in bridge mode, like WiFi or Phone interface)

Yes, of course your suggested as possible alternative approach would work just fine, in that approach the first device is "passthrough" and the other devices even if connected to it will reach anyway internet through the Mikrotik, so the first device would act as two devices, one a switch (passthrough bridge) between only internet and the Mikrotik and the second as a separate bridge between the Mikrotik and the clients.

But i need two bridge on mikrotik… Is it possible? Both with shared internet connection.

If i set a DMZ on main router? As suggested with a proper firewall rules…

I have a router connected on eth1 named eth1_TIM and two bridge configure as i wrote on post 1

/interface list add name=WANcomment="defconf"                                                                                                              
/interface list add name=LAN comment="defconf"     
/interface list member add list=LAN interface=sovicom_bridge comment="defconf"   
/interface list member add list=LAN interface=dax_bridge comment="defconf"                                                                                                                                                                         
/interface list member add list=WAN interface=eth1_TIM comment="defconf"     
/ip firewall {                                                                                                                                              
       filter add chain=input action=accept connection-state=established,related,untracked comment="defconf: accept established,related,untracked"               
       filter add chain=input action=drop connection-state=invalid comment="defconf: drop invalid"                                                               
       filter add chain=input action=accept protocol=icmp comment="defconf: accept ICMP"                                                                         
       filter add chain=input action=accept dst-address=127.0.0.1 comment="defconf: accept to local loopback (for CAPsMAN)"                                      
       filter add chain=input action=drop in-interface-list=!LAN comment="defconf: drop all not coming from LAN"                                                 
       filter add chain=forward action=accept ipsec-policy=in,ipsec comment="defconf: accept in ipsec policy"                                                    
       filter add chain=forward action=accept ipsec-policy=out,ipsec comment="defconf: accept out ipsec policy"                                                  
       filter add chain=forward action=fasttrack-connection connection-state=established,related comment="defconf: fasttrack"                                    
       filter add chain=forward action=accept connection-state=established,related,untracked comment="defconf: accept established,related, untracked"            
       filter add chain=forward action=drop connection-state=invalid comment="defconf: drop invalid"                                                             
       filter add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="defconf: drop all from WAN not DSTNATed"
     }