- Details
- Created on Sunday, 15 July 2012 02:00
- Written by Nicolas
Bernaerts

DNS-323 is a fantastic little NAS storage, able to host 4 Tb of
data thru 2 SATA hard disks up to 2 Tb each.
It offers a lot of embedded possibilities (samba & nfs
shares, iTunes server, uPnp server, ...).
Thanks to a very active community, its possibilities can be
expanded even more thru a scripting method called
ffp.
It allows to start some more services, shaping the DNS-323 into a
very versatile appliance.
Most of the informations you will get in this article has been
collected and consolidated from http://nas-tweaks.net/
& http://wiki.dns323.info/
So, this article will explain in an easy way how to transform
your DNS-323 in a fantastic little home server with lots of open
possibilities left.
All following operations have been done on a DNS 323 (firmware
1.08) with one or two disks, but no RAID configured.
This guide is based on fun_plug
0.5.
You have to be aware that the operations described
in this article are not supported by DLink and will void your
warranty.
Even if everything should go fine, there is always a
slight risk of loosing your hard disk data or even bricking your
NAS.
You are the only one to be held responsible if something
goes wrong for you.
1. Install fun_plug
fun_plug is the name of a script that will run
at the end of the DNS323 boot process.
In fact, during the boot process, the /etc/rc.sh
script calls the /usr/sbin/chk_fun_plug
script.
The /usr/sbin/chk_fun_plug
script checks if a file called fun_plug
is present at the root of the disk /mnt/HD_a2.
If it is there, it executes it. Here is the entry point of a
world of extensions !
A very popular implementation of fun_plug is available from http://www.inreto.de/dns323/fun-plug/
The first thing to do is to go to http://www.inreto.de/dns323/fun-plug/0.5/
and to download :
and to copy them at the root of Volume_1 samba
share.
Next, you just need to reboot your NAS from the Web
interface.
If it is successful, on your Volume_1 share you should see that
:
- fun_plug.tgz has been unpacked to the
ffp directory and has been deleted
- ffp.log is present giving
OK as its last line
Few packages have been installed (busybox, mediatomb, ssh server,
telnet server, ...), but only telnet server is started. It will
allow you to log as root on the box.
The firmware comes with a disabled root account that cannot
login. This is why the fun_plug starts a telnet server that provides
a root shell directly, not asking for any login and password.
So from the telnet session, first thing to do is to enable the
root login and the SSH server.
2. Enable root login
All the commands starting with
$ have to be executed from your desktop.
All the
commands starting with # have to be executed from
the DNS-323 console.
To enable the root account to login (thru ssh ...), you have to
update /etc/shadow &
to set a password for the root account.
You just need to telnet to your NAS :
$ telnet ip.of.your.nas
Trying
192.168.x.x...
Connected to
192.168.x.x.
Escape character is
'^]'.
You then need to activate the root account, by setting the
funplug shell as default.
We also need to create and declare a home directory for the root
account.
# usermod -s /ffp/bin/sh root
usermod:
no changes
# mkdir -p /ffp/home/root/
# sed -ie
's#:/home/root:#:/ffp/home/root:#g' /etc/passwd
Then, throw these commands from the telnet shell :
# pwconv
# passwd
Changing
password for root
Enter the new password (minimum
of 5, maximum of 8 characters)
Please
use a combination of upper and lower case letters and
numbers.
New
password:
Re-enter new
password:
Password changed.
Before you save the changes, you have to run additional checks on
the password and group files.
Some firmware versions duplicate
the ftp user, so we have to fix this.
# pwck
user
admin: directory /home/admin does not exist
user
nobody: directory /home/nobody does not exist
pwck:
no changes
# grpck
grpck:
no changes
You will get some warnings about missing home directories and
invalid group names, just ignore them.
If asked to remove a
duplicate user, say 'yes' to remove one of
them.
If that happens, re-run the commands to check that it's
fixed.
Then, test your changes with the login program using 'root' and
your new password :
# login
NAS
login: root
Password:
Last
login: Sat Jul 14 22:52:33 +0100 2012 on pts/0.
No mail.
If you logged-in succesfully, just save the password files to
flash memory :
# store-passwd.sh
Copying
files to mtd1...
Copying files to
mtd2...
Done.
You are now able to login with the root account thru telnet or
SSH.
3. Enable SSH server
You need to do the first start, where the script will generate
the encription keys. This process may take some time.
# sh /ffp/start/sshd.sh start
Generating
public/private rsa1 key pair.
Your
identification has been saved in
/ffp/etc/ssh/ssh_host_key.
Your
public key has been saved in
/ffp/etc/ssh/ssh_host_key.pub.
The
key fingerprint is:
...
root@NAS
The
key's randomart image is:
+--[RSA1
2048]----+
...
+-----------------+
Generating public/private dsa key
pair.
Your
identification has been saved in
/ffp/etc/ssh/ssh_host_dsa_key.
Your
public key has been saved in
/ffp/etc/ssh/ssh_host_dsa_key.pub.
The
key fingerprint is:
...
root@NAS
The
key's randomart image is:
+--[
DSA 1024]----+
...
+-----------------+
Generating public/private rsa key
pair.
Your
identification has been saved in
/ffp/etc/ssh/ssh_host_rsa_key.
Your
public key has been saved in
/ffp/etc/ssh/ssh_host_rsa_key.pub.
The
key fingerprint is:
...
root@NAS
The
key's randomart image is:
+--[
RSA 2048]----+
...
+-----------------+
Starting
/ffp/sbin/sshd
You should now be able to log to your DNS-323 box with a SSH
client on port 22.
$ ssh
This email address is being protected from spambots. You need
JavaScript enabled to view it.
.x.x
The authenticity of
host '192.168.x.x (192.168.x.x)' can't be
established.
RSA
key fingerprint is ....
Are
you sure you want to continue connecting (yes/no)?
yes
Warning: Permanently
added '192.168.x.x' (RSA) to the list of known
hosts.
root
@192.168.x.x's password:
root@NAS:/mnt/HD_a2/ffp/home/root
#
You are now connected thru SSH !
To enable automatic start of SSH server at boot, you need to set
the execute rights on the script.
# chmod a+x /ffp/start/sshd.sh
The SSH server will start automatically after every NAS
reboot.
4. Disable Telnet access
You have to be sure that you can
sucessfully login to your NAS thru your SSH server before disabling
telnet server.
... or you will have lost console access to your
NAS.
Your Telnet server is still running in parallel to your SSH
server. For security reasons you can disable the Telnet server.
To do so, you just need to remove the execute rights of the
telnet server script.
# chmod -x /ffp/start/telnetd.sh
5. Enable CleanBoot
When you install fun_plug on a DNS-323, it runs
the added programs from the mounted hard disk, so it prevents it
from being unmounted cleanly.
You have this problem if your dmesg
shows the following line:
# dmesg
...
EXT2-fs warning: mounting
unchecked fs, running e2fsck is recommended
...
Cleanboot will modify the reboot & shutdown process to
overcome this issue, allowing you to cleanly reboot or shutdown your
NAS.
To install cleanboot, you need to type the following
commands:
# wget
http://pof.eslack.org/dns323/cleanboot-2.1-ffp05.tgz
Connecting
to pof.eslack.org (178.79.145.151:80)
cleanboot-2.1-ffp05.
100% |*****************| 60076 00:00:00 ETA
# funpkg -i
cleanboot-2.1-ffp05.tgz
Installing package
cleanboot-2.1-ffp05 ...
# chmod a+x
/ffp/start/cleanboot.sh
# /ffp/start/cleanboot.sh start
Setting up
cleanboot...
Your NAS should now cleanly unmount the hard disks if you type
the following commands : halt,
shutdown or
reboot from
the command line.
6. Declare package
repositories
You can now install easily some additionnal packages from some
specific repository.
6.1. Fonz repository
First repository is provided by Fonz. You can install it with
these commands :
# mkdir -p /ffp/pkg/
# cd /ffp/pkg/
#
/ffp/bin/rsync -av --delete inreto.de::dns323/fun-plug/0.5/packages
.
Note that :
- the "." at the end of the line is very
important
- the packages are together over 120 MBytes, so it can take a
while.
After the last file you get some statistics and return to the
command prompt.
This step results in roughly 100 packages being copied (as
tarballs) to the folder /ffp/pkg/packages/.
6.2. Uli repository
Next, you can download additional packages provided by
Uli repository.
# /ffp/bin/rsync -av --delete
ffp.wolf-u.li::ffp/additional .
After the last file you also get some statistics and return to
the command prompt.
This step results in a few packages being copied (as tarballs) to
the folder /ffp/pkg/additional/ and its
subdirectories.
7. Update existing
packages
This procedure has to be followed from
begin to end in one step.
If you don't follow all the steps, you
met get an instable NAS, and worse, you can even be locked out of
your NAS without telnet and SSH access.
To be on the safe side, it's better to enable Telnet … just in
case.
# chmod a+x /ffp/start/telnetd.sh
Then, you can start the package upgrade procedure
# funpkg -u
/ffp/pkg/packages/funpkg*.tgz
# funpkg -u
/ffp/pkg/packages/*.tgz
# funpkg -u
/ffp/pkg/additional/*/*.tgz
Finally, re-enable SSH daemon, in case it has been updated and it
has lost the execute right
# chmod a+x /ffp/start/sshd.sh
If you check, you should see Telnet and SSH allowed to
automatically start during next reboot
# ls -l /ffp/start/*.sh
...
-rwxr-xr-x
1 root root 971 Jul 29 16:30 sshd.sh
...
-rwxr-xr-x 1 root root
169 Aug 12 22:17 telnetd.sh
You can now reboot
# reboot
If you can connect thru SSH without problem, you can now disable
Telnet access
# chmod a-x /ffp/start/telnetd.sh
8. Install Nano editor
Install the packages aspell &
nano :
# funpkg -i
/ffp/pkg/additional/*/aspell*.tgz
# funpkg -i
/ffp/pkg/additional/*/nano*.tgz
Installing
package nano-2.0.9-2 ...
...
[pkgsrc]
Executing install
script for nano-2.0.9-2 ...
Copy the configuration file and edit it.
# cp /ffp/etc/examples/nanorc /ffp/etc/
#
nano /ffp/etc/nanorc
By uncommenting some lines, you can enable the syntax highlight
according to your needs.
In my case, I just need the shell scripts highlighting.
/ffp/etc/nanorc
...
##
Bourne shell scripts
include
"/ffp/share/nano/sh.nanorc"
...
9. Install Midnight
Commander
Install the package :
# funpkg -i
/ffp/pkg/additional/*/mc-*.tgz
Installing
package mc-4.1.40-pre9-1 ...
10. Force IPV4
for RSync Daemon 3.0.9 +
As we have updated all the packages, RSYNC has been updated to
V3.0.9 +.
From version 3.0.9 onward, RSync expects IPV6 to be available on
the host device.
As it is obviously not the case on our fun_plugged DNS-323, RSync
will refuse to start in daemon mode as IPV6 is not available.
So we need to change the start options of the daemon to force
IPV4 only.
# mc -e /ffp/start/rsyncd.sh
/ffp/start/rsyncd.sh
#!/ffp/bin/sh
#
PROVIDE: rsyncd
# REQUIRE: LOGIN
# This script assumes
that the rsync configuration includes
# pid file =
/ffp/var/run/rsyncd.pid
conf_file=/ffp/etc/rsyncd.conf
pid_file=/ffp/var/run/rsyncd.pid
rsync_flags="--daemon
--ipv4
--config=$conf_file"
rsyncd_start()
{
if [ ! -r
"$conf_file" ]; then
echo "Error: Missing
config file $conf_file"
exit 1
fi
x=$(grep '^pid file' $conf_file | cut -d=
-f2)
if [ ${x} != ${pid_file} ];
then
echo "Error: Missing or wrong pid file in
$conf_file (expected: $pid_file)"
exit
1
fi
echo "Starting /ffp/bin/rsync
$rsync_flags"
rm $pid_file
/ffp/bin/rsync
$rsync_flags
}
rsyncd_stop()
{
if [ -r
"$pid_file" ]; then
kill $(cat $pid_file)
2>/dev/null
fi
}
rsyncd_status()
{
if [ -r $pid_file ];
then
rsync_pid=$(cat
$pid_file)
if pidof rsync | grep -wq
$rsync_pid; then
echo "rsyncd
running: $rsync_pid"
else
echo "rsync not running
($pid_file stale)"
fi
else
echo "rsyncd not running"
fi
}
Your DNS 323 is now ready to serve you in a lot of useful
ways.
Hope it helps.