DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2007-01-20 20:55:29

EndUser
Member
Registered: 2007-01-14
Posts: 22

FTP server ports to open?

I tried running the FTP server through my router.  I set it up on a non port 21 port and forwarded the port on my router to the DNS-323's fixed IP.  Folks from the internet do not seem to be able to do a 'ls', something about LIST failing.  (it works locally tho, not thru the router). Since I do not see option for changing the PASV ports, do I need to open up any other port ranges to allow this to work?

Thanks.

Offline

 

#2 2007-01-22 02:09:06

EndUser
Member
Registered: 2007-01-14
Posts: 22

Re: FTP server ports to open?

Im still looking for help here.  When I ran a windows-based FTP server I was able to specify a port ranger for the ports used after a connection is established .. with the DNS-323 there is no such setting, so is it hard coded to something?

Offline

 

#3 2007-01-22 10:51:34

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: FTP server ports to open?

I think the reson for not getting a response is that this is quite complex. The FTP deamon (wu-ftpd) included in the DNS supports this but requires knownlege of your network setup - and I think you'll have to edit some files manually.

If the WU-FTPd included is not configured it'll use ports in the range 1024-65535 according to the source code. The file to check is /etc/ftpaccess and the lines to check for starts with "passive", where both passive address and passive ports needs to be defined properly, I think.

I don't have access to my unit atm but will check my unit later today. The first thing I suggest is to check your router and if it supports some "virtual server" thingie - then you could solve this in the router instead. E.g. the DGL-4300 have a ALG feature which does this and other routers have similar things (sniffing what's going on on port 21, checking the PASV response and opening ports based on response).

I don't know how to do this in WU-FTPd if you have dynamic IP on the WAN side, but if you have a static external IP then it should be possibe to configure this properly in the above mentioned file. Maybe it's just to add the following line in /etc/ftpaccess. At least it looks so in the source code, from a quick glance - don't blame me if it doesn't work.

passive ports 0 20000 20100

If you need more help, I need to know your network setup. I.e. using dynamic or static address on WAN, internal network, etc.

But, as I said above - check your router capabilites first.....



edit: BTW: If your 'internet folks' are not behind firewalls, ask them to use active/PORT instead of passive/PASV.

Last edited by Apskaft (2007-01-22 11:31:55)

Offline

 

#4 2007-01-22 16:46:54

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: FTP server ports to open?

The following is available in 1.01 FW variant of ftpaccess:

passive  ports  0.0.0.0/0    65501   65510

If essence, this means that you need to open up 65501-65510 in your router.

Offline

 

#5 2007-01-22 17:18:05

MiK
Member
From: Sweden
Registered: 2006-12-17
Posts: 102

Re: FTP server ports to open?

Apskaft wrote:

The following is available in 1.01 FW variant of ftpaccess:

1.02 FW uses the same ports

/MiK

Offline

 

#6 2007-01-22 21:04:17

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: FTP server ports to open?

Partly relevant findings in wu-ftpd configurations:

The file /etc/ftpconversations is not setup properly as it refers to non-existent files:

:.Z:  :  :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
:   : :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS
:.gz: :  :/bin/gzip -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:GUNZIP
:   : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP
:   : :.tar:/bin/tar -c -f - %s:T_REG|T_DIR:O_TAR:TAR
:   : :.tar.Z:/bin/tar -c -Z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
:   : :.tar.gz:/bin/tar -c -z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+GZIP
:   : :.crc:/bin/cksum %s:T_REG::CKSUM
:   : :.md5:/bin/md5sum %s:T_REG::MD5SUM


I.e., functions COMPRESS, UNCOMPRESS doesn't work either for .Z or .gz files. Neither does CKSUM and I doubt that MD5SUM works properly. But, I guess these are old bastards that no longer is being used - at least not in a home NAS.

But; if D-Link scans this forum - here's a message: The DNS-323 is not properly setup when it comes to ftp. You're missing a bunch of files (cksum, gzip and compress).

Another interresting finding is that the ftp deamon is setup to allow FXP. This is good for those who enjoys FXP (site-to-site) transfers, but bad for the ones wanting a strict system:

pasv-allow all *


Well, that's all for now.

Offline

 

#7 2007-01-28 04:27:03

EndUser
Member
Registered: 2007-01-14
Posts: 22

Re: FTP server ports to open?

Opening ports 65501-65510 in my router does not make this FTP work.  It only works if I put the NAS on a DMZ port... not something I want to do. 

Any more suggestions?  Different ports?

Offline

 

#8 2007-01-28 21:45:13

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: FTP server ports to open?

Ok, it doesn't work out of the box using PASV. I can confirm this as I've now tested this but the problem can be resolved. The solution is obvious, but you need to understand why it is a problem.

The problem relates to NAT'ed addresses. IPv4 servers really shouldn't be behind NAT as it'll ruin their protocol. The ftp protocol was not written for NAT'ed devices - but some servers "understand" NAT and find's the external IP by "pinging" external nodes.

Neither was ftp inteded to be used with dynamic IP's. A ftp server is a server which should be there - out in the open. But; I surely don't want my DNS in "the open".

Some (most?) routers which implements NAT understand the imposed problems and interferes with the communication (changing 192.168... addresses to external) and hides this problem. This is the most reliable way, but most routers also have problems if you don't used standard ports (i.e. port 21 for ftp).

So; first try to make your router solve this - otherwise, proceed:

Next is to ask your friends to at least try to use PORT instead of PASV. If that is not an option, proceed:

I made this work in the following configuration:

DNS-323 IP: 192.168.0.200
- Listens to port 10021 for FTP, configured via GUI.

External IP: 80.73.10.10 (FAKE, just an example)

Router with ports 10021, 65501-65510 opened. No fancy, no DMZ - just portmapped to IP of DNS-323.


First I stopped ftpdeamon (via GUI)

Then I added the following to /etc/ftpaccess:
passive  address 192.168.0.200 192.168.0.0/16
passive  address 80.73.10.10 0.0.0.0/0

Finally I re-started the ftpdeamon.

The first line will make sure 192.168.0.200 is sent back to ftp client when client is within the NAT. The second line will return the "external IP" when the rest of the world ftp's in.

I'm not sure this will survive a reboot and if you have dynamic external IP you need to change the file whenever you have a new external IP.

I've tested the above in small steps and it "should work" but I'm still awaiting confirmation from external user. Will report back when test is performed.

edit: I can now confirm that the 'hack' above work both behind the firewall/NAT and from external source.

HTH/Apan

Last edited by Apskaft (2007-01-29 08:10:39)

Offline

 

#9 2007-02-03 23:58:49

odelsteken
Member
From: Stockholm, Sweden
Registered: 2007-02-02
Posts: 6

Re: FTP server ports to open?

I stopped the ftpdeamon, edit ftpaccess but when I click on FTP Server in the GUI menu I get a different page than before. For e.g. there's no start/stop button anymore. I'm using IE7 on XP SP2, can that mess things up?

http://www.golfdata.se/andy/dns-323_ftp.gif

Last edited by odelsteken (2007-02-03 23:59:49)

Offline

 

#10 2007-02-04 10:19:45

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: FTP server ports to open?

Can say what went wrong, but you must have modified the file in such a way that the GUI app can no longer parse the file properly. Restore to original file, reboot the device and try again. What editor did you use? Do you have your CRLF properly? You know that file format differ between DOS (Windows) and Linux whenit comes to CRLF vs LF.

So; restore to original file. Use an editor that are 'nice' on Unix file formed (i.e. UltraEdit) and only add the two lines I mention above, right after the passive *** already present.

If you cannot get it to work, post you ftpaccess file here and I'll have a look at it.

HTH/Apan

Offline

 

#11 2007-02-04 13:03:44

odelsteken
Member
From: Stockholm, Sweden
Registered: 2007-02-02
Posts: 6

Re: FTP server ports to open?

I had the same issue with the Itunes server earlier, when I turned it off I couldn't get it on again without having to restore all settings first.

Anyway, even though I turned off the ftpdeamon I can still FTP towards the dns-323. How can I copy ftpaccess to my computer? I tried copy and mcopy in telnet, but I neither of them to work.

I can also add that after I've pressed FTP server in the GUI, none of the other actions work. For e.g. if I press tools I just get a "Internet Explorer cannot display the webpage" message. I have to re-enter the IP address and login again in order to do anything. Weird!

Last edited by odelsteken (2007-02-04 13:05:05)

Offline

 

#12 2007-02-04 16:35:45

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: FTP server ports to open?

First you telnet into the device. Then, copy the file /etc/ftpaccess to /mnt/HD_a2. Note that you're now on a Un*x system and not a PC. The command to copy a file is "cp". So, "cp /etc/ftpaccess /mnt/HD_a2/." should do it. Then you can access the file from your PC in \\DNS_xxx\HDD_1\ftpaccess.

I noticed that there is a ftpaccess.default in the /etc directory, which you could use to replace your modified version with: cp /etc/ftpaccess.default /etc/ftpaccess"


Please be warned that all commands you execute on the DNS are volatile. You might brick your device if you don't know what you're doing. It's VERY VERY easy to brick it....

/Apan

Offline

 

#13 2007-02-04 21:30:41

odelsteken
Member
From: Stockholm, Sweden
Registered: 2007-02-02
Posts: 6

Re: FTP server ports to open?

I restarted my dns-323 and when I opened ftpaccess after that the content was totally different from before. I did the changes above and reconfigured the port in GUI (after editing ftpaccess). It works like a charm!! smile

Thanks a lot!!

Offline

 

#14 2007-02-07 11:47:00

Apskaft
Member
From: Karlskrona, Sweden
Registered: 2007-01-09
Posts: 165

Re: FTP server ports to open?

This is now covered in the WiKi: http://dns323.kood.org/howto:open_ports_ftpd /Apan

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB