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 2011-02-09 06:35:47

infinitemonkeys
New member
Registered: 2011-02-09
Posts: 2

Advantage of hacking DNS-323

I'm an experienced sysadmin, so I'm confident I can piece through the various instructions to hack the DNS-323.  What I'm wondering is, why?  I've read through much of the site, but can't find any killer reason.

I'm sure there must be one for there to be this entire site on hacking the box and getting it to do extra tricks, but I don't really see much to entice me into the effort.  You can telnet and change iTunes, FTP and other add-ons, but basically telnet is just to configure it and the others are replacements for existing functionality.  I searched the forums and main site but don't see anyone enumerating all the wondrous advantages of fun_plugging and doing all the warrantee breakage.  I'm past the time when exploits for the sake of exploits are fun.

I'm sure there are advantages and hope there is someone on the site willing to take a minute and list them.  Sell me a reason.
And if you do, then I'd also like to read some specifics about whether hacking the NAS can improve file access and transfer rates or other networking tweaks.  Those would definitely be worthwhile.

Thanks

Offline

 

#2 2011-02-09 07:12:55

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: Advantage of hacking DNS-323

I guess it depends what you want. If you only want a samba fileserver then you may not have a killer reason. For me it is.
+ NFS server that actually works
+ Nightly backups from one disk to another
+ Http server, nice to have for sharing stuff with others in a very easy way
+ ssh/sftp access to your data
+ fsck to detect and correct disk inconsistencies

Last edited by bjby (2011-02-09 07:19:46)

Offline

 

#3 2011-02-09 07:20:12

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Advantage of hacking DNS-323

For me, it was an excellent bit-torrent client and rss feed parser (Transmisison and Automatic).

I also have a USB drive connected which is not available OOTB.

Turning off the defective time server and configuring so that DST works properly was a nice bonus as well as turning off a number of services that I don't want to increase available resources.

Many reasons to install FFP, but like bjby says, if you don't see a reason that applies to you, then don't bother.

Last edited by FunFiler (2011-02-09 07:22:06)


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#4 2011-02-09 08:45:44

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Advantage of hacking DNS-323

For me it was:
1. The daily incremental snapshots (rsync) of a PC on my LAN and from one drive to the other.
2. A torrent client that works (Transmission).
3. Modified smb.conf so to force the DNS-323 to be the master browser in order to solve some mapped network drive problem I had from my XP box.
4. Placed all torrent files on a mounted USB drive in hope to reduce wear and tear of HDD (not sure if it was worth it, hoped to see that drive in stand by).
5. In the future, probably going to add a UPnP/DLNA media server.

But as the others have answered - for each his own.
I'm not into hacking for the sake of hacking myself. More of a necessity is the mother of invention type of guy.

@FunFiler: Which services did you turn off?


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#5 2011-02-09 15:08:35

fordem
Member
Registered: 2007-01-26
Posts: 1938

Re: Advantage of hacking DNS-323

infinitemonkeys wrote:

I'm an experienced sysadmin, so I'm confident I can piece through the various instructions to hack the DNS-323.  What I'm wondering is, why?  I've read through much of the site, but can't find any killer reason.

A bit of a strange question - why does anyone "hack" anything - and FWIW, I'm using hack here in the older, more purist sense of the term.

The first reason is - because we can - and the second, and probably more realistic one, is to make it, to our way of thinking, better, or simply better suited to our particular needs & environment.

I just want a SMB server - but I want one that can do unattended shutdown on command from my UPS - and when I bought mine, UPS support was not included in the firmware, and even though it is there now, it doesn't work the way I want it.

What warranty breakage?  If I pull my disks there's no trace that it's ever been hacked.

Offline

 

#6 2011-02-09 16:06:27

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Advantage of hacking DNS-323

scaramanga wrote:

@FunFiler: Which services did you turn off?

I removed everything to to with the print server as I use the USB port for a disk, not a printer. I also removed all the time server/update functions as they were defective. Setting the proper TZ is all that is required. I rarely use the admin console to make any changes to the system so I see no point in leaving it running, so the web admin (webs) is off unless I need it for something.

That's it I think off the top of my head.

On the "hacking" issue, I don't really classify it as that as running fun_plug on boot up is actually a DLink function, just undocumented and unsupported. I prefer the term "exploiting" smile

I don't hack my devices just because I can, I do it when there is a distinct advantage. I looked at all the services and options available abd decided it was worth it to me. There was of course an element of fun and I enjoy prgramming and scripting so it was a win all around.

It runs pretty clean now:
/ # ps -ef
PID   USER     COMMAND
    1 root     init
    2 root     [ksoftirqd/0]
    3 root     [events/0]
    4 root     [khelper]
    5 root     [kthread]
   11 root     [kblockd/0]
   14 root     [khubd]
   49 root     [pdflush]
   50 root     [pdflush]
   52 root     [aio/0]
  189 root     [scsi_eh_0]
   51 root     [kswapd0]
  190 root     [scsi_eh_1]
  200 root     [mtdblockd]
  217 root     [kcryptd/0]
  218 root     [kmirrord/0]
  231 root     [loop0]
1331 root     xmldb -n config
1374 root     [md0_raid1]
1562 root     chkbutton
1616 root     fancontrol 1
1625 root     op_server 3 3 3
1631 root     -sh
1668 root     check_hotplug
1757 root     atd
1809 root     mserver
1810 root     apkg
1936 root     [scsi_eh_2]
1937 root     [usb-storage]
2007 root     /ffp/sbin/telnetd -l /ffp/bin/sh
2113 root     crond
21699 root     /ffp/bin/automatic -v 2 -c /ffp/etc/automatic.conf -a -l /mnt/HD
21718 nobody   /ffp/bin/transmission-daemon -f -g /mnt/HD_a2/usb/transmission
21720 nobody   /ffp/bin/transmission-daemon -f -g /mnt/HD_a2/usb/transmission
21721 nobody   /ffp/bin/transmission-daemon -f -g /mnt/HD_a2/usb/transmission
21722 nobody   /ffp/bin/transmission-daemon -f -g /mnt/HD_a2/usb/transmission

Last edited by FunFiler (2011-02-09 16:12:31)


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#7 2011-02-09 16:58:19

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Advantage of hacking DNS-323

FunFiler wrote:

I removed everything to to with the print server as I use the USB port for a disk, not a printer. I also removed all the time server/update functions as they were defective. Setting the proper TZ is all that is required. I rarely use the admin console to make any changes to the system so I see no point in leaving it running, so the web admin (webs) is off unless I need it for something.

1. How did you remove the server/update functions, and are you referring to the firmware update functions or the time/clock functions? 
2. How did you stop (and how do you startup on command) the webs?  Just kill the process?  But how do you restart it?

Thanks

Offline

 

#8 2011-02-09 17:39:12

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Advantage of hacking DNS-323

I do a number of things in fun_plug.local including

Code:

# Fix time zone information.
echo "Setting Time Zone information in /etc/TZ to EST5EDT,M3.2.0,M11.1.0"
echo "EST5EDT,M3.2.0,M11.1.0" > /etc/TZ
# fix /etc/services
if ! grep -w ntp /etc/services >/dev/null; then
  echo "ntp 123/udp" >>/etc/services
fi
/ffp/bin/ntpd -g -q -c /ffp/etc/ntpd.conf > /mnt/HD_a2/usb/logs/ntpd_run.log

# Get rid of the lpd process since we don't use a print spooler
/ffp/bin/killall lpd

This sets the proper TZ variable and stops the print spooler.

I have a complicated addcron.sh script in ffp/start that does a whole pile of things including removing the time and daylight savings time functions

Code:

# Check for saved default cron jobs
if [ ! -f $CRONFILE ]; then
  echo "Saving default crontab entries to $CRONFILE"
  /bin/crontab -l >$CRONFILE
  echo "Removing timezone related entries"
  sed -i "/daylight/d" $CRONFILE
  sed -i "/rtc/d" $CRONFILE
  sed -i "/stime/d" $CRONFILE
fi

I can't recall if the admwebs.sh and kickwebs.sh scripts were default or I got them off the wiki, but I use them to stop and start the admin web interface.

Code:

#!/ffp/bin/sh
#
# This script was created by Paul on 2/2/08 as a work around
# in getting the admin website off of port 80 and on to port 81
# It is used in conjuction with lighttpd.sh (also modified) which
# calls this script. When used from lighttpd.sh it stops the
# web admin service then starts lighttpd on port 80. The web admin
# service notices that something is on port 80 and then starts on
# port 81.
#
# NOTE:
# ./fun_plug.d/etc/lighttpd.conf needs to be configured to use
# port 80
#
# NOTE2: (2/14/08)
#  Updated this script to remove "Starting" webs. Apparently
#  if you start webs you will not be able to add users
#  webs is set to automatically restart if the /web/webs service
#  is stopped.
#

admwebs_start() {
    if [ -x "/web/webs" ]; then
#       echo "Starting webs... "
#       /web/webs & > /dev/null
        echo "/webs/webs service will start automatically in 45 sec"
    else
        echo "ERROR: /web/webs not found or not executable"
    fi
}

admwebs_stop() {
    killall webs
}

admwebs_status() {
    if [ -n "$(pidof webs)" ]; then
        echo "running"
    else
        echo "stopped"
    fi
}

case "$1" in
    stop)
        admwebs_stop
        ;;
    restart)
        admwebs_stop
        sleep 1
        admwebs_start
        ;;
    status)
        admwebs_status
        ;;
    start|'')
        admwebs_start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|status"
        ;;
esac

Code:

#!/ffp/bin/sh

# PROVIDE: kickwebs
# REQUIRE: LOGIN
# BEFORE: lighttpd

. /ffp/etc/ffp.subr
name="kickwebs"
start_cmd="kickwebs_start"
stop_cmd=:

kickwebs_start()
{
  echo "Kicking webs ..."
  killall webs
}

run_rc_command "$1"

Nothing really exciting and for the most part stuff I got off here.

Last edited by FunFiler (2011-02-09 17:43:46)


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#9 2011-02-09 18:11:23

scaramanga
Member
Registered: 2010-08-04
Posts: 251

Re: Advantage of hacking DNS-323

bound4h beat me to the punch. Thanks for the additional detail, FunFiler.


DNS-323 HW Rev. C1 FW 1.10 fun-plug 0.5
2 x WD10EARS-00Y5B1 in Standard mode (LCC set to 5 min; Aligned to 4K)
Transmission with Transmission Remote GUI

Offline

 

#10 2011-02-09 18:56:27

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Advantage of hacking DNS-323

Happy to share.


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#11 2011-02-09 19:29:28

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Advantage of hacking DNS-323

FunFiler,

The admwebs and kickwebs seem to do the same thing in terms of stopping webs.  Is there a reason you use kickwebs to stop webs as opposed to just admwebs_stop from the admwebs.sh script?  Sorry if I'm missing something obvious.  I don't see lighttpd mentioned anywhere, so maybe thats what the kickwebs does?

Thanks

Offline

 

#12 2011-02-09 20:28:02

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Advantage of hacking DNS-323

No particular reason. Just came across it when I was looking at setting up lighttpd, which serves as a backup web server and is offline until another automated script kicks it in. It worked so I stuck with it.


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#13 2011-02-10 10:01:10

Thiam
Member
Registered: 2007-06-18
Posts: 43

Re: Advantage of hacking DNS-323

- clean unmount of the disks on shutdown/restart (cleanboot)
- file system check on boot (yafsck.sh)
- one DNS-323 is my SqueezeboxServer
- mount USB stick on the SqueezeboxServer and use it for /tmp, logging and swap so the disks can go to sleep
- use SMART tools (had a failed drive last year)

Offline

 

#14 2011-02-10 15:51:01

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Advantage of hacking DNS-323

Thiam wrote:

- mount USB stick on the SqueezeboxServer and use it for /tmp, logging and swap so the disks can go to sleep

I was thinking about this too. Any tricks or words of advice? I assume it is fairly straight forward as a remap is simple enough. Just need to copy the existing files?


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#15 2011-02-10 18:55:36

Thiam
Member
Registered: 2007-06-18
Posts: 43

Re: Advantage of hacking DNS-323

FunFiler wrote:

Thiam wrote:

- mount USB stick on the SqueezeboxServer and use it for /tmp, logging and swap so the disks can go to sleep

I was thinking about this too. Any tricks or words of advice? I assume it is fairly straight forward as a remap is simple enough. Just need to copy the existing files?

I didn't copy any files to the USB stick. The executables and the database are still on the disks. The disks will spin down at night or while I'm at work. When you wake up the system, there is a delay for the disks to spin up. I turn of my controllers most of the time and I have the impression that starting a controller causes the disks to spin up. Since the controllers are slow to boot, my system is ready by the time the menus are available.

You need to manually add the temp path for MySQL in my.cnf, otherwise MySQL uses /tmp.
/tmp is in the system image and thus limited by it's size. It isn't large enough for collections over 10000 tracks. Scanning fails.

Swap is easy: put swapon -p 0 /dev/sdc2 in one of the startup scripts (assuming sdc2 is a swap partition defined on your stick)
You will need an fdisk that runs on the DNS-323 to create partitions on the stick. (or do it on a working linux system)

The logging folder is a documented parameter for the slimserver program, so I've added that to the slimserver.sh startup script.


Swap on an USB stick slows down the squeezebox server (even more), and scanning. Scanning my 12000 track collection only succeeds once in about three times, it usually locks up the OS (no telnet, no web interface). My el-cheapo stick doesn't handle several hours of write abuse very well, it seems. I've once seen an I/O error in dmesg about it. I've stopped doing full rescans with swap on USB enabled.

Last edited by Thiam (2011-02-10 18:56:35)

Offline

 

#16 2011-02-10 20:03:05

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Advantage of hacking DNS-323

Ok, I misunderstood what you were doing. You are chainging the tmep locations used by the programs. What I want to do is mount /tmp directly to a location on the USB stick. I played with it once, but didn't make it permanent.


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#17 2011-02-10 21:02:06

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Advantage of hacking DNS-323

The hack ability of these DNS323 boxes is outstanding.  Some of the things this has allowed me to do without overwriting the vendor firmware include:

1. Updating to a newer kernel that supports things like NFS and iSCSI properly, the reloaded functionality is awesome.
2. Getting a better web interface than the POS that the dns-323 comes with (alt-f firmware is awesome)
3. Creating a debian squeeze chroot package for the before mentioned alt-f firmware, which allows using any debian-arm package that doesn't require kernel modules.
    So far I've done these things with the chroot:
       1. Added iscsi and AoE support which I've been using to play with live migration of virtual machines.  I was even able to add web configuration of them to the alt-f web interface.
       2. Installed various packages that have web interfaces and embedded their configuration into an iframe in the alt-f web interface (so far I experimented with sabnzbdplus and cups)


I can see some real potential for future hackability.  Some things I'm hacking on include:

A fun_plug loader.  That brings up a web gui for a set time (2 minutes by default) and presents a menu of all the fun_plugs that are installed so it's possible to select the fun_plug to boot, kind of like grub.  Hopeful it will make it easier to experiment with fun_plugs that could potentially hang the nas.

Also, at this point I don't see any unsurmountable roadblocks that would prevent porting openfiler over to the dns-323.  I've gotten the web interface to come up and so far it looks like there are 3 issues to completing a port:

1. The debian squeeze pam php authentication module needs to get fixed.  Not sure if the issue is with pam/php or openfiler, but since it's the pam process that is hanging and sucking up 100% CPU I'm guessing it's a pam issue.
2. Need to get the reloaded functionality booting the debian kernel/initrd, so the needed kernel modules are available.
3. Need to patch OpenFiler to partition disks in a manner that is compatible with the dlink firmware (Currently a boot into the stock dlink firmware causes a prompt to erase the disk)

Offline

 

#18 2011-02-14 00:27:19

Thiam
Member
Registered: 2007-06-18
Posts: 43

Re: Advantage of hacking DNS-323

FunFiler wrote:

Ok, I misunderstood what you were doing. You are chainging the tmep locations used by the programs. What I want to do is mount /tmp directly to a location on the USB stick. I played with it once, but didn't make it permanent.

That's how I resolved the problem with /tmp being too small before I found out about the setting in my.cnf.
I simply did a 'mount /tmp /dev/sdc4 -o noatime' in /mnt/HD_a2/.bootstrap/setup.sh


Regarding the USB I/O errors, I had them again this afternoon while trying to integrate SugarCube with SBS.
dmesg reports things like this:
SCSI error : <4 0 0 0> return code = 0x70000
end_request: I/O error, dev sdc, sector 3729846
SCSI error : <4 0 0 0> return code = 0x70000
end_request: I/O error, dev sdc, sector 3729854
SCSI error : <4 0 0 0> return code = 0x70000
end_request: I/O error, dev sdc, sector 3729862
SCSI error : <4 0 0 0> return code = 0x70000

and after a while:

SCSI error : <4 0 0 0> return code = 0x70000
end_request: I/O error, dev sdc, sector 3309390
Buffer I/O error on device sdc4, logical block 0
lost page write due to I/O error on sdc4
EXT2-fs error (device sdc4): ext2_get_inode: unable to read inode block - inode=8181, block=32915
SCSI error : <4 0 0 0> return code = 0x70000
end_request: I/O error, dev sdc, sector 3817398

Buffer I/O error on device sdc4, logical block 0
lost page write due to I/O error on sdc4
EXT2-fs error (device sdc4): ext2_free_branches: Read failure, inode=8178, block=63501
SCSI error : <4 0 0 0> return code = 0x70000
end_request: I/O error, dev sdc, sector 3572710

and

SCSI error : <4 0 0 0> return code = 0x70000
end_request: I/O error, dev sdc, sector 3309390
Buffer I/O error on device sdc4, logical block 0
lost page write due to I/O error on sdc4
EXT2-fs error (device sdc4): read_block_bitmap: Cannot read block bitmap - block_group = 1, block_bitmap = 32913

Buffer I/O error on device sdc4, logical block 0
lost page write due to I/O error on sdc4
EXT2-fs error (device sdc4): ext2_readdir: bad page in #2

At the moment, I didn't bother yet what kind of failire these errors point too, but it definitly seems read related. Too bad RAM on a USB interface doesn't exist in order to extend the memory of our little box.

Offline

 

#19 2011-02-15 06:47:00

chriso
Member
Registered: 2009-03-29
Posts: 74

Re: Advantage of hacking DNS-323

My humble list is:
* Backup from one disk to the other (rsync/link, and subverion {used to binary diff large Quicken data file})
* Offline back up to Amazon S3
* Fix time.
* subversion server for software code and financial data backup.
* Perl and extra modules used for backups and to use access and store financial data from web site.
* ssh access.
* run from ffp/scripts from USB flash drive so hard drives can shutdown when not in use.
* Ability to hook up USB hard drive and rsync backup hard drive to it.
* clean shutdown.

Last edited by chriso (2011-02-15 06:50:26)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB