
The D-Link DNS-323 NAS is great. It runs Linux, is infinitely tweakable and plays nicely with most devices I have at home including my MacBook, my Linux boxes and my Wii running MPlayer CE which I use to watch DivX on my TV.
Of course, to install new software on the DNS-323, you must have fun_plug properly activated.
Installing Avahi on the DNS-323
Install both with
funpkg -i libdaemon-0.13-1.tgz funpkg -i avahi-0.6.24-1.tgz
2) Add an avahi user
groupadd -g 50 avahi useradd -u 50 -g avahi -d /tmp -s /bin/false avahi
3) Create a startup script called /ffp/start/avahi.sh as shown here.
#!/ffp/bin/sh
# PROVIDE: avahi
# REQUIRE: SERVERS
. /ffp/etc/ffp.subr
name="avahi"
command="/ffp/sbin/avahi-daemon"
avahi_daemon_flags="-D -s"
required_files="/ffp/etc/avahi/avahi-daemon.conf /ffp/etc/avahi/hosts"
start_cmd="avahi_start"
avahi_start()
{
# need avahi user and group for priviledge separation
if ! grep '^avahi:' /etc/passwd >/dev/null; then
echo 'avahi:x:50:50:Avahi Daemon:/no/where:/bin/false' >>/etc/passwd
fi
if ! grep '^avahi:' /etc/shadow >/dev/null; then
echo 'avahi:*:14493:0:99999:7:::' >>/etc/shadow
fi
if ! grep '^avahi:' /etc/group >/dev/null; then
echo 'avahi::50:avahi' >>/etc/group
fi
proc_start $command
}
run_rc_command "$1"
4) Make the file executable so that avahi starts when the DNS-323 boots
chmod +x /ffp/start/avahi.sh
5) Create /ffp/etc/avahi/services/smb.service
<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
</service-group>
6) Create /ffp/etc/avahi/services/http.service
<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_http._tcp</type>
<port>80</port>
</service>
</service-group>
7) Create /ffp/etc/avahi/services/device-info.service (This changes the ICON shown in Mac OS X)
<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=RackMac</txt-record>
</service>
</service-group>
8 ) Launch avahi
/ffp/start/avahi.sh
Installing AFP (netatalk) on the DNS-323
1) Get db42 and netatalk and install both with
funpkg -i db42-4.2.52-1.tgz funpkg -i netatalk-2.0.4-1.tgz
2) Create a startup script called /ffp/start/afpd.sh as shown here.
#!/ffp/bin/sh
# PROVIDE: afpd
# BEFORE:
# REQUIRE:
. /ffp/etc/ffp.subr
name="afpd"
start_cmd="afpd_start"
stop_cmd="afpd_stop"
status_cmd="afpd_status"
afpd_start()
{
/ffp/sbin/afpd
}
afpd_stop()
{
killall afpd
}
afpd_status()
{
ps -A | grep /ffp/sbin/afpd | grep -v grep
}
run_rc_command "$1"
3) Make it executable with
chmod +x /ffp/start/afpd.sh
4) Create /ffp/etc/avahi/services/afpd.service as show here.
<?xml version="1.0" standalone="no"?><!--*-nxml-*--> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_afpovertcp._tcp</type> <port>548</port> </service> </service-group>
5) Use the “vipw” command and change some details for the default “nobody” user so that Mac OS X can use that user to log in.
nobody:x:501:501:Linux User,,,:/home/nobody:/ffp/bin/bash
Give a password to that user and store the password (in clear text) in the user’s home directory as shown here.
passwd nobody cd /home mkdir nobody echo "secret" > nobody/.passwd chown -R nobody: nobody
It is essential to store this user’s information in the flash memory of the DNS-323. Do this with:
store-passwd.sh
6) Modify /ffp/etc/netatalk/AppleVolumes.default to add the required shares. Mine looks like:
# The "~" below indicates that Home directories are visible by default. # If you do not wish to have people accessing their Home directories, # please put a pound sign in front of the tilde or delete it. # ~ /mnt/HD_a2 Volume_1 /mnt/HD_b2 Volume_2
Notice that I have commented the ~ because I don’t want the user to have a home directory on the DNS-323. I only want to access Volume_1 and Volume_2.
7) Start netatalk
/ffp/start/afpd.sh start
Making Mac OS X Leopard play nice with Netatalk
To allow Leopard to connect to AFP shares with clear text (unencrypted) passwords, do as shown here:
# to be done on the Mac and not the DNS-323 sudo defaults write com.apple.AppleShareClient "afp_cleartext_allow" -bool YES sudo defaults write com.apple.AppleShareClient "afp_cleartext_warn" -bool YES
Enjoy!
You can now connect to the DNS-323 from a Mac and get optimal performance. Phew. Linux is sooooo fun… for geeks like me
5 November 2009 update: Instead of creating a new user, the existing user “nobody” is used. This allows the DNS-323 to be used through AFP and SMB transparently as SMB uses “nobody” by default. Interestingly, when the DNS-323 reboots, its /home directory starts anew and therefore will lack a /home/nobody directory (with its .passwd file) but this does not seem to trouble Mac OS X.
Great hack!
The DNS-323 looks like a great little NAS: flexible and affordable too. With AFP enabled, it could be a viable alternative to using Time Capsules over gigabit.
Apart from streaming videos and storing/sharing data, are you using it with Time Machine? Also, how’s the iTunes server and power consumption?
There are a lot of people using the DNS-323 with Time Machine and it works
Personally I am not a Time Machine fan. I prefer knowing what files and directories I’m deleting
In fact, the DNS-323 has 2 hard disks which are normally used in RAID 1 configuration (mirroring.) Personally, I do not use them as a RAID 1 array. What I do is that I use one as a normal external drive (hosting most of my multimedia content including videos of the kids growing.) Then, once a week, I backup all of that drive to the second one using rsync. So I have two copies of most of my multimedia files on two separate hard disks in the same enclosure. I am planning of getting a similar-sized hard disk at work where I’ll do a backup, say, every month so that I have:
[MacBook] —- [HD1 on NAS] — [HD2 on NAS] — [HD at work]
Where did you buy it ?
I had to order one (as the DNS-323 was not available in Mauritius…) through a very reliable company I like dealing with: BBCWyse in Vacoas.
are you using a snow leopard or leopard with this DNS?
Some how i can’t get afp to work on Snow Leopard.
Hi, I use Leopard and everything works. I’ve not tried Snow Leopard with the DNS-323 though…
Hello avinash
Thanks for posting this.
I was able to follow the steps until I reached the “5) Use the “vipw” command…” step.
It would be nice if you could “clarify” this step.
Sorry if it is obvious, I’m totally new at this
Thanks
J
Trying to get this working with DNS-321. I’ve tried searching Network for my device and typing afp://mydevice with no luck.
The only error I get is:
useradd: unknown GID 1000
It seems to create the user fine though.
Does store-passwd.sh work with the DNS-321?
Anyone have an idea what i should check?
Hi JertoZ,
Maybe you don’t have vipw installed. In that case, use the normal vi:
vi /etc/passwd
I just finished setting up afp and now it wont let me sign in to the Volume (I was able to after avahi). I did everything to the T but It wont let me in, it just tells me “You entered an invalid username or password. Please try again.”
I have a DNS-323 with one 750Gb hard drive, running 1.07 w/ funpack 0.5 and no other programs running(besides telnet). I am on a Mac Book Pro running Snow Leopard 10.6.2.
Any help is greatly appreciated.
Hi Ty,
Are you sure you did the
sudo defaults write com.apple.AppleShareClient “afp_cleartext_allow” -bool YES
sudo defaults write com.apple.AppleShareClient “afp_cleartext_warn” -bool YES
I am not 100% sure but I think there is also a problem when using Snow Leopard. I use Leopard personally… Have a look at http://macstuff.beachdogs.org/blog/?p=79
Avinash,
Thanks for the reply. I will have to try it again as I reformatted. But I think the problem was due to the fact that I was running in 64bit mode. oops
Can you explain this, as the web site “here” to me is having me do something different:
“Give a password to that user and store the password (in clear text) in the user’s home directory as shown here.
1.
passwd nobody
2.
cd /home
3.
mkdir nobody
4.
echo “secret” > nobody/.passwd
5.
chown -R nobody: nobody”
Also, am I really creating a “nobody” user with a password of “secret” or do I create a actual user name and password.
Thanks again.
The user “nobody” already exists by default. For instance, when one connects to the DNS-323 using SMB, it’s trough that user. We want, in fact, to reuse the same “nobody” user for AFP connections as well. For this to work, a cleartext password should be stored in /home/nobody/.passwd
Just redid everything, and it WORKS! The only thing that is different is the fact I’m running in 32 bit mode…go figure.
I’m glad
I think I’ll keep Leopard for the time being… and only upgrade to Snow Leopard when really really needed.
Thanks for the AFP tips here. Side question from reading your description above. I have been trying to connect my Wii to my DNS-323 using Mplayer’s smb shares but am having no luck. I can connect to my SMB shares from my Mac and XP machines without issue. I did edit the smb.conf file as well.
Did you have to do anything differently in Mplayer’s smb.conf files?
Hi Bob,
I have a Wii too and, after having modified mplayer’s configs appropriately, it connects to the DNS-323 without any problem. Check the smb url.
Avinash, your procedure worked.. except that I am not able to connect to the afp share from dns 323 thru my snow leopard computer..
it works if I re-define in my AppleVolumes.default to say mnt/HD_a2/subfolder Volume_1.. where subfolder is any subfolder within Volume_1… but it doesn’t seem to work for just Volume_1.. because of which I can access only one sub directory under Volume_1 and not the other directories/files under the root Volume_1.
do you know why this happens? I have done everything outlined in your procedure above..
I think I may solved my problem.. AFP connection to Volume_1 fails due to the presence of certain hidden files under Volume_1.. namely the .AppleDB and .AppleDesktop and .AppleDouble Files.
these are hidden files and not readily visible unless you do an ls -a command..
once deleted.. it is able to connect with no problems.
Thanks for this wonderful procedure.
p.s. for creating the .service files I went to the actual forum to copy paste.. I think you may be missing a few lines in the starting line of the .service code.
I’m glad everything works now, Partha.
I’l check for the .service files… but, as far as I know, those are the exact same lines I’m using on my own DNS-323 and everything seems to work well.
Hello Avinash.. for example.. in the afpd.sh section.. the line “run_rc_command “$1″” is missing I believe at the end…
Also, if you compare this line “#
” as written by you .. to the document that is reffered here (from the dns 323 forum).. .. that one says..
notice the addition dashes after next to the *.
I am not even sure if affects it’s workings in anyway.. but for the longest time I had trouble making it work when I simply copy pasted your code… could be because of the lines as I mentioned above.. or could be also because of the fact that the RED colored words in your code above when pasted, puts in a “b” (for bold I guess) next to the word automatically, thus causing an error.
This time I followed your procedure.. but went to the original referenced sites to copy and paste it on to my device files.. and it worked wonderfully.
I don’t mean to be picky.. I can’t thank you enough for putting this thing together and making our lives so much easier. AFP is proving to be much superior to samba (even the latest samba).. especially when using Plex or xbmc.
thank you.
“”Also, if you compare this line “#
” as written by you .. to the document that is reffered here (from the dns 323 forum).. .. that one says..
notice the addition dashes after next to the *.”"
sorry, some lines didn’t get in when I posted this comment…
what I am highlighting above is the comparison between the lines
(the first line in the .service files which begins with xml).. to the first line in the .service file as written in the dns 323 forum... there are additional dashes in the xml line (first line) of the .service code as shown on the forum.
Man, to ene boss, mo pou seye sa taler, Mo ti p liter depi dns wiki mais to explication paret plis simple
Thanks a lot Partha.
You’re right. There was a run_rc_command “$1″ missing in afpd.sh and, for some reason, WordPress was transforming my double dashes into one single long dash…
Thanks for taking the time to point out those to me. As you can see, I’ve corrected the mistakes.
I can’t seem to download netatalk from the above link. I get a 404 not found. I downloaded it from sourceforge but the package doesn’t install because it says that ffp is not in the package. I’m not a linux/unix guru so I could use a little help.
Thx.
Never mind… I found 2.0.5-1 in the directory. Thx
I’m having some problems with your afpd.sh and avahi.sh scripts running correctly. I’m using a 321, so that could be part of it… or that I know nothing about scripting.
The problem appears to be in the PROVIDE and REQUIRE lines. The message I get in the ffp.log is:
* Running /ffp/etc/rc …
rcorder: requirement `SERVERS
‘ in file `/ffp/start/avahi.sh’ has no providers.
rcorder: requirement `
‘ in file `/ffp/start/afpd.sh’ has no providers.
I’m really not sure what this means since I don’t understand what role those lines play in the script. I do know the process never starts, and the problem is in the same part of the script if I try to run it from command line.
Hi Bearinator,
Make sure the quotes in the two files are single quotes ‘ and not backticks `. Sometimes, things get mixed up when doing copy paste.
Avinash,
Thanks for the help. This didn’t work though — the quotes are single quotes and not backticks. Any other ideas?
What exact error message are you having?
Above is the message that is given in ffp.log. If I try to launch the script from command prompt I get:
sh avahi.sh start
: not foundine 2:
: not foundine 5:
avahi.sh: .: line 6: can’t open /mnt/HD_a2/ffp/etc/ffp.subr
sh afpd.sh start
: not foundne 2:
: not foundne 6:
afpd.sh: .: line 7: can’t open /ffp/etc/ffp.subr
I’ve checked permissions on everything (the scripts, ffp.subr, rc) and they’re all executable. I should add that I have a standard ffp 0.5 install.
My Full log file looks like this:
ln -snf /mnt/HD_a2/ffp /ffp
* Running /ffp/etc/fun_plug.init …
* Running /ffp/etc/rc …
rcorder: requirement `SERVERS
‘ in file `/ffp/start/avahi.sh’ has no providers.
rcorder: requirement `
‘ in file `/ffp/start/afpd.sh’ has no providers.
* /ffp/start/syslogd.sh inactive
* /ffp/start/SERVERS.sh inactive
* /ffp/start/portmap.sh inactive
* /ffp/start/unfsd.sh inactive
* /ffp/start/nfsd.sh inactive
* /ffp/start/ntpd.sh inactive
* /ffp/start/smartd.sh inactive
* /ffp/start/LOGIN.sh inactive
* /ffp/start/telnetd.sh inactive
* /ffp/start/svnserve.sh inactive
* /ffp/start/sshd.sh …
Starting /ffp/sbin/sshd
* /ffp/start/rsyncd.sh inactive
* /ffp/start/mysqld.sh inactive
* /ffp/start/mediatomb.sh inactive
* /ffp/start/kickwebs.sh inactive
* /ffp/start/lighttpd.sh inactive
* /ffp/start/inetd.sh inactive
* /ffp/start/dnsmasq.sh inactive
* /ffp/start/btpd.sh inactive
* /ffp/start/avahi.sh …
/ffp/etc/rc: line 45: /ffp/start/avahi.sh: not found
* /ffp/start/afpd.sh …
/ffp/etc/rc: line 45: /ffp/start/afpd.sh: not found
* OK
To be frank @Bearinator, I don’t know what’s wrong with your install. Maybe you should have a look at http://wiki.dns323.info/ and ask someone there… Sorry.
No problem, thanks for trying to help.