Page 1 of 1

Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 2:30 pm
by dawe4444
Hello,

I'm pretty new into a networking world.

I'm trying to do dstnat on a bridged network. I'm using the default firewall rules that came out of the box with the router. I'm using the "Use IP Firewall" on the bridge. When I configure the dstnat in IP Firewall the traffic on the port doesn't get port-forwarded. Could someone help me sort this out ?

Thank you !

Re: Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 2:33 pm
by dawe4444
Posting the firewall rule list.
Flags: X - disabled, I - invalid, D - dynamic 
 0  D ;;; special dummy rule to show fasttrack counters
      chain=forward action=passthrough 

 1    ;;; defconf: accept established,related,untracked
      chain=input action=accept connection-state=established,related,untracked log=no log-prefix="" 

 2    ;;; defconf: drop invalid
      chain=input action=drop connection-state=invalid log=no log-prefix="" 

 3    ;;; defconf: accept ICMP
      chain=input action=accept protocol=icmp log=no log-prefix="" 

 4    ;;; defconf: accept to local loopback (for CAPsMAN)
      chain=input action=accept dst-address=127.0.0.1 log=no log-prefix="" 

 5    ;;; defconf: drop all not coming from LAN
      chain=input action=drop in-interface-list=!LAN log=no log-prefix="" 

 6    ;;; defconf: accept in ipsec policy
      chain=forward action=accept log=no log-prefix="" ipsec-policy=in,ipsec 

 7    ;;; defconf: accept out ipsec policy
      chain=forward action=accept log=no log-prefix="" ipsec-policy=out,ipsec 

 8    ;;; defconf: fasttrack
      chain=forward action=fasttrack-connection connection-state=established,related log=no log-prefix="" 

 9    ;;; defconf: accept established,related, untracked
      chain=forward action=accept connection-state=established,related,untracked log=no log-prefix="" 

10    ;;; defconf: drop invalid
      chain=forward action=drop connection-state=invalid log=no log-prefix="" 

11    ;;; defconf: drop all from WAN not DSTNATed
      chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN log=no log-prefix="" 

Re: Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 2:36 pm
by mkx
Please post your dst-nat rules. And use export instead of print ...

Re: Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 2:37 pm
by xvo

Re: Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 2:51 pm
by anav
Why are you using IP firewall on the bridge, vice sticking just with the input chain and forward chain??
/export hide-sensitive file=anynameyouwish

Re: Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 3:05 pm
by dawe4444
here is the export:
# jul/12/2020 14:00:54 by RouterOS 6.47.1
# software id = xxxxxx
#
# model = RBD52G-5HacD2HnD
# serial number = xxxxxxxxxx
/interface bridge
add admin-mac=74:4D:28:83:F1:89 auto-mac=no comment=defconf name=bridge
/interface wireless
# managed by CAPsMAN
# channel: 2412/20-Ce/gn(17dBm), SSID: wifi_ssid, CAPsMAN forwarding
set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-XX \
    distance=indoors frequency=auto installation=indoor mode=ap-bridge ssid=\
    MikroTik-83F18D station-roaming=enabled wireless-protocol=802.11
# managed by CAPsMAN
# channel: 5260/20-Ceee/ac/DP(17dBm), SSID: wifi_ssid, CAPsMAN forwarding
set [ find default-name=wlan2 ] band=5ghz-a/n/ac channel-width=\
    20/40/80mhz-XXXX country=slovakia distance=indoors frequency=auto \
    installation=indoor mode=ap-bridge ssid=wifi_ssid station-roaming=enabled \
    wireless-protocol=802.11
/caps-man datapath
add bridge=bridge name=datapath1
/caps-man security
add authentication-types=wpa-psk,wpa2-psk encryption="" name=security1
/caps-man configuration
add country=slovakia datapath=datapath1 name=config security=security1 ssid=\
    wifi_ssid
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
    dynamic-keys supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/ip pool
add name=dhcp ranges=192.168.170.10-192.168.170.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=bridge name=defconf
/caps-man manager
set enabled=yes
/caps-man manager interface
set [ find default=yes ] forbid=yes
add disabled=no interface=bridge
/caps-man provisioning
add action=create-dynamic-enabled master-configuration=config
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=wlan1
add bridge=bridge comment=defconf interface=wlan2
/interface bridge settings
set use-ip-firewall=yes
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface wireless cap
# 
set caps-man-addresses=127.0.0.1 enabled=yes interfaces=wlan1,wlan2
/ip address
add address=192.168.170.1/24 comment=defconf interface=ether2 network=\
    192.168.170.0
add address=192.168.68.113/24 interface=ether1 network=192.168.68.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server lease
add address=192.168.170.54 client-id=1:0:11:32:9f:a0:3e mac-address=\
    00:11:32:9F:A0:3E server=defconf
add address=192.168.170.106 mac-address=02:11:32:2F:24:9A server=defconf
add address=192.168.170.44 client-id=1:78:4f:43:a0:7f:32 mac-address=\
    78:4F:43:A0:7F:32 server=defconf
add address=192.168.170.42 client-id=1:40:3c:fc:5:5a:56 mac-address=\
    40:3C:FC:05:5A:56 server=defconf
/ip dhcp-server network
add address=192.168.170.0/24 comment=defconf dns-server=192.168.170.1 \
    gateway=192.168.170.1 netmask=24
/ip dns
set allow-remote-requests=yes servers=192.168.170.106
/ip dns static
add address=192.168.170.106 comment=defconf name=router.lan type=A
/ip firewall filter
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
    ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
    ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
    connection-state=established,related
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
/ip route
add distance=1 gateway=192.168.68.100
/system clock
set time-zone-name=Europe/Bratislava
/system identity
set name=xxxxx
/system leds settings
set all-leds-off=after-1min
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

Re: Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 3:16 pm
by anav
Couple of observations

(1) The interface should be consistent including ip address which should refer to the bridge!!
/ip address
add address=192.168.170.1/24 comment=defconf interface=ether2 network=\
192.168.170.0

(2) Also it looks like you do not have a public IP address but a natted address from something else and its a fixed wanip.
It may be more appropriate for you to have a source nat rule that looks like this
add chain=srcnat action=src-nat to-addresses=fixedwanip (instead of the masquerade rule).

(3) I dont see any need for your firewall IP firewall bridge setting (unless its needed for capsman)?

(4) In terms of destination NAT, you have not destination nat rules in your config is probably the reason port forwarding is not working for you.

Need:
A. general firewall rule in the forward chain (already there), Done!
B. source nat rule (done)
C. dstnat rule.

add chain=dstnat action=dst-nat protocol=xxx, dst-port=xxxx \
dst-address=fixedwanip to-addresses=ipofserver

Re: Can't do dstnat on a bridged network.  [SOLVED]

Posted: Sun Jul 12, 2020 9:34 pm
by dawe4444
Couple of observations

(1) The interface should be consistent including ip address which should refer to the bridge!!
/ip address
add address=192.168.170.1/24 comment=defconf interface=ether2 network=\
192.168.170.0

(2) Also it looks like you do not have a public IP address but a natted address from something else and its a fixed wanip.
It may be more appropriate for you to have a source nat rule that looks like this
add chain=srcnat action=src-nat to-addresses=fixedwanip (instead of the masquerade rule).

(3) I dont see any need for your firewall IP firewall bridge setting (unless its needed for capsman)?

(4) In terms of destination NAT, you have not destination nat rules in your config is probably the reason port forwarding is not working for you.

Need:
A. general firewall rule in the forward chain (already there), Done!
B. source nat rule (done)
C. dstnat rule.

add chain=dstnat action=dst-nat protocol=xxx, dst-port=xxxx \
dst-address=fixedwanip to-addresses=ipofserver
Thanks very much for your response and help. I tried your suggestions but without success. here is the export again.
# jul/12/2020 20:30:50 by RouterOS 6.47.1
# software id = xxxxxx
#
# model = RBD52G-5HacD2HnD
# serial number = xxxxxxxx
/interface bridge
add admin-mac=74:4D:28:83:F1:89 auto-mac=no comment=defconf name=bridge
/interface wireless
# managed by CAPsMAN
# channel: 2412/20-Ce/gn(17dBm), SSID: X5, CAPsMAN forwarding
set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-XX distance=indoors frequency=auto installation=indoor mode=ap-bridge ssid=MikroTik-83F18D station-roaming=enabled \
    wireless-protocol=802.11
# managed by CAPsMAN
# channel: 5260/20-Ceee/ac/DP(17dBm), SSID: X5, CAPsMAN forwarding
set [ find default-name=wlan2 ] band=5ghz-a/n/ac channel-width=20/40/80mhz-XXXX country=slovakia distance=indoors frequency=auto installation=indoor mode=ap-bridge ssid=X5 station-roaming=enabled \
    wireless-protocol=802.11
/caps-man datapath
add bridge=bridge name=datapath1
/caps-man security
add authentication-types=wpa-psk,wpa2-psk encryption="" name=security1
/caps-man configuration
add country=slovakia datapath=datapath1 name=config security=security1 ssid=X5
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=dynamic-keys supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/ip pool
add name=dhcp ranges=192.168.170.10-192.168.170.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=bridge name=defconf
/caps-man manager
set enabled=yes
/caps-man manager interface
set [ find default=yes ] forbid=yes
add disabled=no interface=bridge
/caps-man provisioning
add action=create-dynamic-enabled master-configuration=config
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=wlan1
add bridge=bridge comment=defconf interface=wlan2
/interface bridge settings
set use-ip-firewall=yes
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface wireless cap
# 
set caps-man-addresses=127.0.0.1 enabled=yes interfaces=wlan1,wlan2
/ip address
add address=192.168.170.1/24 comment=defconf interface=bridge network=192.168.170.0
add address=192.168.68.113/24 interface=ether1 network=192.168.68.0
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server lease
add address=192.168.170.54 client-id=1:0:11:32:9f:a0:3e mac-address=00:11:32:9F:A0:3E server=defconf
add address=192.168.170.106 mac-address=02:11:32:2F:24:9A server=defconf
add address=192.168.170.44 client-id=1:78:4f:43:a0:7f:32 mac-address=78:4F:43:A0:7F:32 server=defconf
add address=192.168.170.42 client-id=1:40:3c:fc:5:5a:56 mac-address=40:3C:FC:05:5A:56 server=defconf
/ip dhcp-server network
add address=192.168.170.0/24 comment=defconf dns-server=192.168.170.1 gateway=192.168.170.1 netmask=24
/ip dns
set allow-remote-requests=yes servers=192.168.170.106
/ip dns static
add address=192.168.170.106 comment=defconf name=router.lan type=A
/ip firewall filter
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related
add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN
/ip firewall nat
add action=src-nat chain=srcnat comment="defconf: masquerade" to-addresses=192.168.68.113
add action=dst-nat chain=dstnat dst-address=192.168.68.113 dst-port=1194 protocol=udp to-addresses=192.168.170.54 to-ports=1194
/ip route
add distance=1 gateway=192.168.68.100
/system clock
set time-zone-name=Europe/Bratislava
/system identity
set name=X5_CAPSMAN
/system leds settings
set all-leds-off=after-1min
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN

Re: Can't do dstnat on a bridged network.

Posted: Sun Jul 12, 2020 10:58 pm
by anav
Nothing hits me as obvious, must be off my game :-(. but perhaps modify this
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN

To
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new dst-address=192.168.68.113
in-interface=ether1

Re: Can't do dstnat on a bridged network.

Posted: Mon Jul 13, 2020 12:14 am
by mkx
Where are connections you want to dst-nat coming from? WAN or LAN? If it's WAN, then your dst-nat rule should do the trick. If it's LAN, then you don't need bridge firewall, but hair-pin nat.

Re: Can't do dstnat on a bridged network.

Posted: Mon Jul 13, 2020 12:02 pm
by dawe4444
The WAN IP is: 192.168.68.113

Re: Can't do dstnat on a bridged network.

Posted: Mon Jul 13, 2020 1:58 pm
by anav
Are you attempting to connect to the server from within the lan using that WANIP,
If that is not a public IP, which public IP do people use to reach your server??

Re: Can't do dstnat on a bridged network.

Posted: Mon Jul 13, 2020 5:15 pm
by dawe4444
OK, so a simple dstnat did the trick. I was thinking I'm going nuts. Finally called my little ISP and talked to they network admin. Turns out there the Public IP was shared amongst others and it was nated on their side. Once he made adjustments it's fully working now.