Community discussions

MikroTik App
 
SuperMario
just joined
Topic Author
Posts: 8
Joined: Sat Mar 06, 2021 10:25 am

Open ftp only for WAN-IP-range

Sat Mar 06, 2021 10:48 am

Hi all,

My ftp-NAS has from time-to-time brute-force attacks that makes exploding the log file. Most of the time from China.
Anyway I only want to grant ftp-access from Belgium.
So I have created & uploaded a white-list from https://mikrotikconfig.com/firewall/ (great tool btw). The (white) list is called "CountryIPAllow".

I have masquerade on port 21 to access the ftp from inside LAN & dynamic hairpin (wich updates my WAN-IP) to access ftp from WAN.
Other ports than 21 are forwarded to other devices so those should not be blocked.

I've seen examples to drop requests from a blacklist, but my blacklist if to heavy, so I need to do the inversed rule.
How should I configure the firewall allow "CountryIPAllow" and drop all orther port-21-access ?

Many thanks in advance!
 
SuperMario
just joined
Topic Author
Posts: 8
Joined: Sat Mar 06, 2021 10:25 am

Re: Open ftp only for WAN-IP-range  [SOLVED]

Mon Mar 08, 2021 9:23 am

Update

I found the solution :
  • Install the list following the instructions in the video (found on the same page)
  • Then add 2 rules to the firewall:
    • /ip firewall filter add chain=forward action=accept protocol=tcp dst-address-list=CountryIPAllow src-port=21 log=no log-prefix=""
    • /ip firewall filter add chain=forward action=drop protocol=tcp src-port=21 log=no log-prefix=""

Warning : the last rule also drops connections from inside to external ftp-servers.So I added a new rule to allow ftp-outgoing traffic.
 
erlinden
Forum Guru
Forum Guru
Posts: 1958
Joined: Wed Jun 12, 2013 1:59 pm
Location: Netherlands

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 9:46 am

There are better options than FTP, but it is your choice. Port 21 is not sufficient for FTP, if it is working (the data part) you might want to investigate why.
 
SuperMario
just joined
Topic Author
Posts: 8
Joined: Sat Mar 06, 2021 10:25 am

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 10:39 am

It is working in that sense that the login-screen is not showing anymore for other IP's than BE. My goal was achieved.
I'm not an expert in this domain, and more than happy to accept other/better solutions.
 
erlinden
Forum Guru
Forum Guru
Posts: 1958
Joined: Wed Jun 12, 2013 1:59 pm
Location: Netherlands

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 11:02 am

For data you have to forward a passive port range (configured in the FTP server). You might want to consider SFTP (from a security perspective).
 
SuperMario
just joined
Topic Author
Posts: 8
Joined: Sat Mar 06, 2021 10:25 am

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 11:12 am

Ah now I understand.
Unfortunately my NAS does not support SFTP.
 
erlinden
Forum Guru
Forum Guru
Posts: 1958
Joined: Wed Jun 12, 2013 1:59 pm
Location: Netherlands

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 11:22 am

What NAS are you using? FTPS might be an option...
 
SuperMario
just joined
Topic Author
Posts: 8
Joined: Sat Mar 06, 2021 10:25 am

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 12:09 pm

It's a DNS-320L
No sftp possible.
 
erlinden
Forum Guru
Forum Guru
Posts: 1958
Joined: Wed Jun 12, 2013 1:59 pm
Location: Netherlands

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 12:56 pm

FTPS is not the same as SFTP.
According to this forum you should be able to use SSL/TLS:
http://forums.dlink.com/index.php?topic=60539.0
 
SuperMario
just joined
Topic Author
Posts: 8
Joined: Sat Mar 06, 2021 10:25 am

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 1:00 pm

Thanks for the tip - I'll give it a try later on.
 
tdw
Forum Guru
Forum Guru
Posts: 1847
Joined: Sat May 05, 2018 11:55 am

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 2:16 pm

Given how buggy various NAS appliances seem to be, and that regular FTP sends your credentials in plaintext which anyone can snoop, allowing access from even some of the internet is a bad idea - using a VPN would help.
 
SuperMario
just joined
Topic Author
Posts: 8
Joined: Sat Mar 06, 2021 10:25 am

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 2:34 pm

I see, but that is impossible. I have about 50 customers needing to access the ftp from several places. Moreover : my customers do not have IT-department able to setup a vpn. It's not worth it.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19323
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Open ftp only for WAN-IP-range

Mon Mar 08, 2021 2:43 pm

Let me blunt, if you run an ftp server plain you will get hacked. Its like a beacon on the internet.
Now I dont know crap about that stuff, but If I suspect that anybody using your server if hacked would then become vulnerable as well through their FTP connection.........not funny!!

Recommend some form of encryption as indicated so at least passwords are protected somewhat.
Now in terms of users, why is it public to the internet? I am assuming you have either family or a close knit group of friends that do so.
Well thats easy then.
All you need to do is insist to use your server they need to provide you with a domain name that you can put in your firewall address list.

Such that your dstnat rule for the server looks like this.
add action=dst-nat chain=dstnat comment="Access To My NAS"
dst-port=portX,portY,portZ in-interface-list=WAN log=yes \
protocol=tcp src-address-list=Authorized_Users to-addresses=local_server_ip

where your firewall address list for external users looks like.

/ip firewall address-list
add address=mydomain.net comment=george Authorized_Users
add address=new.home.net comment=sally Authorized_Users
add address=freedomain.net comment=mom-dad Authorized_Users
add address=signme.up.org comment=cousin Authorized_Users
add address=free.dyn.org comment=frank Authorized_Users

There are many free domain name services out there.
The beauty about the above is that the router will resolve them to IP addresses for you.

Who is online

Users browsing this forum: Bing [Bot] and 103 guests