Community discussions

MikroTik App
 
upviqq
newbie
Topic Author
Posts: 39
Joined: Thu Jun 02, 2016 10:18 am

Port forwarding not working

Tue May 15, 2018 8:41 am

I need to open samba share from internet for a couple of minutes, but usual port forwarding rule doesn't work.
Can you help me?
And I know about samba security issues, so firstly I tried with "src-address=my_current_address", but it didn't work.
So trying most simple rule, doesn't work too. Forwarding all 137,138, 139 and 445 ports.
/ip firewall nat add action=netmap chain=dstnat dst-port=139 protocol=tcp to-addresses=192.168.123.123 to-ports=139
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: Port forwarding not working

Tue May 15, 2018 9:13 am

I'm not sure action=netmap accepts a single IP address as to-addresses value, you should use action=dst-nat instead. And put back the src-address=your.current.ip.address, as it was not the reason why it did not work. Plus you don't need to use to-ports if you don't need to change the original dst-port value.
 
User avatar
Anumrak
Forum Guru
Forum Guru
Posts: 1174
Joined: Fri Jul 28, 2017 2:53 pm

Re: Port forwarding not working

Tue May 15, 2018 9:15 am

try action dst-nat instead of netmap and specify in-interface.
 
User avatar
Anumrak
Forum Guru
Forum Guru
Posts: 1174
Joined: Fri Jul 28, 2017 2:53 pm

Re: Port forwarding not working

Tue May 15, 2018 9:16 am

I'm not sure action=netmap accepts a single IP address as to-addresses value, you should use action=dst-nat instead. And put back the src-address=your.current.ip.address, as it was not the reason why it did not work. Plus you don't need to use to-ports if you don't need to change the original dst-port value.
you're never sleep, hah
 
upviqq
newbie
Topic Author
Posts: 39
Joined: Thu Jun 02, 2016 10:18 am

Re: Port forwarding not working

Tue May 15, 2018 10:13 am

try action dst-nat instead of netmap and specify in-interface.
No, didn't help.
I have several perfectly working forwards like rdp, vnc and ssh, but problem with samba.
 
User avatar
Anumrak
Forum Guru
Forum Guru
Posts: 1174
Joined: Fri Jul 28, 2017 2:53 pm

Re: Port forwarding not working

Tue May 15, 2018 10:31 am

try action dst-nat instead of netmap and specify in-interface.
No, didn't help.
I have several perfectly working forwards like rdp, vnc and ssh, but problem with samba.
Do you have counters moving in this rule? If yes, then problem in PCs.
 
RoadkillX
Frequent Visitor
Frequent Visitor
Posts: 88
Joined: Sun Apr 22, 2018 6:00 pm
Location: Spain

Re: Port forwarding not working

Tue May 15, 2018 1:07 pm

try action dst-nat instead of netmap and specify in-interface.
No, didn't help.
I have several perfectly working forwards like rdp, vnc and ssh, but problem with samba.
Samba also uses 445 for file sharing it is after all microsoft-ds so same port you'd open on windows, 139 you don't need across the internet they'll get to you by public ip address or dns name no need for Netbios name resolution, use a dst-nat rule to forward 445 to your samba host and may god help you, security wise i mean. make sure you have the latest build of samba pkg for you distro.
 
upviqq
newbie
Topic Author
Posts: 39
Joined: Thu Jun 02, 2016 10:18 am

Re: Port forwarding not working

Wed May 16, 2018 9:18 am

Counters are zero, nothing helps.
Tried several PC's with public shared folder allowed for all to read/write.
 
RoadkillX
Frequent Visitor
Frequent Visitor
Posts: 88
Joined: Sun Apr 22, 2018 6:00 pm
Location: Spain

Re: Port forwarding not working

Wed May 16, 2018 11:23 am

Export your filter, mangle and Nat rules.
 
upviqq
newbie
Topic Author
Posts: 39
Joined: Thu Jun 02, 2016 10:18 am

Re: Port forwarding not working

Wed May 16, 2018 12:02 pm

Export your filter, mangle and Nat rules.
Mangle is empty. NAT is full of netmap rules, simple port forwarding, no samba ports.
/ip firewall filter
add action=accept chain=input comment=PPTPD dst-port=1723 protocol=tcp
add action=drop chain=forward dst-address-list="***" protocol=!icmp src-address=192.168.123.123
add action=accept chain=forward comment="defconf: accept established,related" connection-state=established,related
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid log-prefix=INVALID
add action=drop chain=forward comment="defconf:  drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=internet
add action=accept chain=input comment=defconf connection-state=established,related
add action=drop chain=input comment=defconf in-interface-list=internet
/ip firewall nat
add action=masquerade chain=srcnat out-interface-list=internet src-address=192.168.123.0/24
 
RoadkillX
Frequent Visitor
Frequent Visitor
Posts: 88
Joined: Sun Apr 22, 2018 6:00 pm
Location: Spain

Re: Port forwarding not working

Wed May 16, 2018 12:34 pm

Again all rules are needed to determine which one is causing the problem something is forwarding your publicip:445 to an internal host before it gets to the samba dst-nat rule,try in nat move the samba dst-nat to the begginng of the list am sure it'll work or your samba is blocking connections.

*netmap - creates a static 1:1 mapping of one set of IP addresses to another one. Often used to distribute public IP addresses to hosts on private networks

Not familiar with this, but clearly if your nat chain is full of netmaps you're mapping 1:1 so you can't use the same public ip of any netmap rules for samba since the port 445 is already mapped to another internal ip.
 
upviqq
newbie
Topic Author
Posts: 39
Joined: Thu Jun 02, 2016 10:18 am

Re: Port forwarding not working

Wed May 16, 2018 2:30 pm

Again all rules are needed to determine which one is causing the problem something is forwarding your publicip:445 to an internal host before it gets to the samba dst-nat rule,try in nat move the samba dst-nat to the begginng of the list am sure it'll work or your samba is blocking connections.

*netmap - creates a static 1:1 mapping of one set of IP addresses to another one. Often used to distribute public IP addresses to hosts on private networks

Not familiar with this, but clearly if your nat chain is full of netmaps you're mapping 1:1 so you can't use the same public ip of any netmap rules for samba since the port 445 is already mapped to another internal ip.
No, there are not even 3-digit ports in my rules, only 2,4,5-digits.
Placed rules on top of list - nothing changes.
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: Port forwarding not working

Wed May 16, 2018 2:43 pm

I may be wrong, but I believe action=netmap ignores ports even if you provide dst-port as rule parameter. So if a netmap rule is before a dst-nat one and matches, the dst-nat one never sees the packet.
 
upviqq
newbie
Topic Author
Posts: 39
Joined: Thu Jun 02, 2016 10:18 am

Re: Port forwarding not working

Wed May 16, 2018 2:48 pm

I may be wrong, but I believe action=netmap ignores ports even if you provide dst-port as rule parameter. So if a netmap rule is before a dst-nat one and matches, the dst-nat one never sees the packet.
No, I have several netmap rules with different ports. I can change any netmap action to dst-nat action and it works. And I tried to place samba rules on top.
 
sindy
Forum Guru
Forum Guru
Posts: 10206
Joined: Mon Dec 04, 2017 9:19 pm

Re: Port forwarding not working

Wed May 16, 2018 2:49 pm

OK. In such case, add
/ip firewall mangle
add action=passthrough chain=prerouting protocol=tcp dst-port=139
add action=passthrough chain=prerouting protocol=tcp dst-port=445
and then move these two rules as high in the chain as possible (i.e. make them the very first static rules in that chain).

If they count packets when you attempt the SMB connection, the issue is in your firewall; if they don't, your ISP is blocking the port whose rule does not count.
 
RoadkillX
Frequent Visitor
Frequent Visitor
Posts: 88
Joined: Sun Apr 22, 2018 6:00 pm
Location: Spain

Re: Port forwarding not working

Wed May 16, 2018 2:49 pm

if you can, post the netmap rules and remove public ips from them, not sure if hide-sensitive will do that. Maybe you missed something or misunderstood how something works and someone else can spot it, can't troubleshoot with limited information.
*netmap - creates a static 1:1 mapping of one set of IP addresses to another one. Often used to distribute public IP addresses to hosts on private networks
netmap is a direct 1:1 mapping public to private there is no port choosing here that is in dst-nat.

You're not getting any traffic on the dst-nat rule for samba so the problem is in mangle since that is the packet flow.
Flow.png
If they count packets when you attempt the SMB connection, the issue is in your firewall; if they don't, your ISP is blocking the port whose rule does not count.
i wouldn't discard this, it's very possible if you are just been handed /24 bit address blocks and ISP knows you're corporate and might be unpatched.
 
upviqq
newbie
Topic Author
Posts: 39
Joined: Thu Jun 02, 2016 10:18 am

Re: Port forwarding not working

Wed May 16, 2018 3:05 pm

I think the problem is ISP, mangle counts zero packets from internet, but packets from lan are counted.
I'll figure it out from ISP.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 172 guests