Slow SMB transfers in Mac OS 10.12.2

I’m using a 802.11ac WLAN to connect to my Synology NAS. With the last Mac OS 10.12.2 update the network performance was catastrophic when I tried to access the NAS via SMB. At first I thought this might have been caused by the WLAN connection but even with a Gigabit LAN connection my transfer rates were around 3-5MB/s.

After a short search online, I’ve a few hits describing the actual problem:

Apple uses their own version of SMB and enabled client signing to mitigate against Man in the middel attacks. Therefore all connections underly this signing process and are way slower.

Therefore I’ve disabled client-signing on my mac using this command:

This will write this content

 

to the file /etc/nsmb.conf. After you’ve set this value you need to unmount all samba shares. If you’ll reconnect now, you’ll witness a much better performance, starting with faster loading of network shares.

You can revert this change with

 

Automount network shares on Mac OS for use in iTunes

I’ve moved my iTunes library from my Macbook’s SSD to my Synology NAS on a network share. This is quite easy and can be made inside the iTunes preferences pane. After you’ve changed the path for the iTunes Media, all iTunes managed media will be moved to the new location (assuming you let iTunes manage your files of course :)).

This allows you to have your iTunes library on your Macbook while all the large files are stored on the NAS. This is especially important for larger libraries as well as the newer Macbooks which only have a limited flash drive instead of larger harddisks.

However, there is one important problem with this solution: Once you’ve disconnected from this network share for whatever reasons and you try to start iTunes, you’ll have your iTunes Media folder reset to your user’s music folder on your boot disk. You’ll now need to reset the path to your files again, and this will again cause iTunes to check all files if they are on the right location and moves them if necessary.

I thought I’ve taken care of this problem with auto connecting to the network share with a Login Item. However, this didn’t help me much since I sometimes have disconnections to my network (e.g. when I’m on the road) and the network connection will only be created once during the login of your current user. So this doesn’t help me at all and caused me to look for another better solution.

So I’ve found this gist (the link is dead) and modified it a little bit to my environment. Therefore here’s my short list of modifications for using autofs in combination with AFP or SMB volumes:

If you now start up iTunes again, it will try to locate the media files in the /Volumes/music folder, like I manually specified it. However, autofs will now automatically mount the network share for me and iTunes won’t complain about a missing volume. This way I won’t ever need to take care of manually updating the path once I forgot connecting to my NAS 🙂

Update:
Hm, it seems that the trick with /../Volumes does not work anymore on Mac OS 10.11.4 🙁 If I try to list the content of the mounted volume an error message is returned:

ls: : Unknown error: 118

So I need to mount the volume in a different folder and need to change the path in iTunes again.

Update 2:
I’m not able to mount afp volumes anymore so I’m using smbfs like it is described here. However, this will require a user and password in the configuration file 🙁

Update 3:

Mac OS Sierra breaks the autofs configuration. I had to change it a little bit according to this SuperUser entry. The Gist is updated accordingly.

How to use client certificates with Synology VPN Server and OpenVPN

The holidays are near and I want to have access to my files on my Synology NAS, while I’m visiting my family. That’s why I’m showing you today how to configure the official Synology VPN server to use OpenVPN with client certificates instead of username/password.

 

1. Start with a custom root CA

First of all you need your own self-signed root CA. A useful tool is XCA but you can also do this from the terminal.

2. Create a certificate for your DiskStation

Create a new Certificate for your DiskStation. Be aware to use the assigned DNS name, otherwise your browser will complain when you try to connect to the web interface of the DiskStation.

3. Configure the DiskStation to use the server certificate

I’m using DSM 5. There’s a nice new Security setting in the system settings. You can define and upload a certificate there:

Import CertificateThe Private Key and Certificate fields are straight forward. However, the intermediate certificate is the tricky part I forgot. This is the certificate of your self signed root CA. Only with this additional certifacte the trust chain is complete.

4. Trusting the root CA

The next step depends on your computers OS. I’m using Mac OS where I can easily add the root CA certificate as an always trusted certificate.

5. Reload the web interface of your DiskStation

After you’ve set the certificate, the web interface should have been reloaded. Eventually you’ve been warned by your browser about a security issue (you did not trusted your root CA, therefore the web page was untrusted). After a reload and the instructions from step 4, this warning should go away. If you take a look at the certificate tab of the DiskStation’s security setting, you will see that your new server certificate is active.

6. Install the VPN Server

Install the VPN Server from Synology’s Package Center. Its configuration is done from the start menu.

7. Configure the VPN Server

Enable OpenVPN from the Settings of the VPN Server. For more details see Synology’s instructions.

8. Connect via SSH to your DiskStation

Disable user authentication on the DiskStation and enable the certificate based authentication (code taken from this wiki) in this file: /usr/syno/etc/packages/VPNCenter/openvpn/openvpn.conf

 

9. Configure your client

I’m only using iOS devices and Macs. Therefore this is again a little biased 🙂 The installation of the clients for Mac and Windows is explained on Synology’s page. iOS is explained on this page (only in german but with screenshots). The initial configuration can be downloaded from the OpenVPN settings page from the DiskStation web interface. The extracted zip file contains the servers official certificates but needs to be modified to add support for the client certificates. Text is taken again from same wiki as above.

 

The DiffieHellmann Parameters (dh) can also be created with XCA. I would recommend 2048, since 4096 takes ages to generate.

10. Give it a try

Now you can test your VPN connection on your devices. It should not ask for a password, instead it should use the my.crt and my.key you’ve set in the configuration.

Synology DiskStation 5 – Mapping of external USB drives

The mapping of external USB drives in Synologys Diskstation 5 is a mystery to me. The order of connected drives does not seem to be of interest and keeps being the same even after a reboot. Especially after the latest update to DiskStation 5, my DiskStation 213+ assigned other than usual drive numbers to my external USB drives. This results in broken backup plans and network volumes.

A little Google research led me to this forum entry together with a suitable solution:

  • Unmount/Eject all connected external USB drives
  • Disconnect the drives from the DiskStation
  • Connect with telnet/ssh to your DiskStation and edit the file /usr/syno/etc/usbno_guid.map
  • The number gives you the name of the usbshareX mount point, while the guid behind the equal sign identifies your USB drive. The last entries will propably your connected drives as you can access them from their usbshareX mount points.
  • Remove unwanted entries and restore the number to their original position.
  • Reboot the DiskStation.
  • Reconnect your Devices, starting with the drive with the lowest number first.
  • All done.

Synology DiskStation Download Station access to temporary BitTorrent files

My Synology DS-213+ can be used as a BitTorrent client. The necessary package „Download Station“ is available for free in the standard repositories of the DiskStation. If you use the Download Station for BitTorrent downloads, you may want to access files from the torrent early and before the complete torrent is finished.

In this case you could assume that the setup download folder would be also used as a place for these temporary files. But the Download Station uses a hidden folder for these files. It’s only visible if you login to your DiskStation using SSH or Telnet. It’s the folder „/volume1/@download“.

If you want to continue to download and want to check the folders content at the same time, you will need to mount this folder to a shared folder which is accessable via SMB or AFP and their likes. The command

mount --bind /volume1/@download /volume1/your-shared-folder"

will mount this hidden folder into your-shared-folder. This way you can access all temporary files. But be aware, that this command will only last until you reboot your DiskStation. By the way: I’m not alone with this wish to access the temporary files. Some people in the official Synology forum also decided to ask for this feature.