<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.deadcode.net</title>
	<atom:link href="http://blog.deadcode.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.deadcode.net</link>
	<description></description>
	<lastBuildDate>Thu, 05 Apr 2012 05:58:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Install OpenVPN Client on Nexus S</title>
		<link>http://blog.deadcode.net/2011/12/08/install-openvpn/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-openvpn</link>
		<comments>http://blog.deadcode.net/2011/12/08/install-openvpn/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 15:51:00 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Nexus S]]></category>
		<category><![CDATA[OpenVPN]]></category>

		<guid isPermaLink="false">http://blog.deadcode.net/?p=3331</guid>
		<description><![CDATA[<p>Steps below is how I setup OpenVPN client on my Nexus S to connect to the OpenVPN server on my Synology NAS DS207+.</p> Root the phone first. Go to market and download busybox . Install busybox to /system/xbin. Go to market and download ES File Explorer. Using ES file explorer and mount root / [...]]]></description>
			<content:encoded><![CDATA[<p>Steps below is how I setup OpenVPN client on my Nexus S to connect to the <a href="http://blog.deadcode.net/openvpn" title="Synology DS207+ usage series 7 - Setup OpenVPN server (Routed mode) on DS207+ with dual authentication and Windows/DS101j/TomatoVPN OpenVPN Client" target="_blank">OpenVPN server on my Synology NAS DS207+</a>.</p>
<ol>
<li><a href="http://blog.deadcode.net/2011/12/07/root-nexus-s/" title="Root Nexus S 2.3.6" target="_blank">Root the phone first</a>.</li>
<li>Go to market and download <a href="https://market.android.com/details?id=stericson.busybox&#038;feature=search_result#?t=W251bGwsMSwxLDEsInN0ZXJpY3Nvbi5idXN5Ym94Il0." title="Busybox for Android" target="_blank">busybox </a>.  Install busybox to /system/xbin.</li>
<li>Go to market and download <a href="https://market.android.com/details?id=com.estrongs.android.pop&#038;feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5lc3Ryb25ncy5hbmRyb2lkLnBvcCJd" target="_blank">ES File Explorer</a>. Using ES file explorer and mount root / as writable.</li>
<li>Go to market and download <a href="https://market.android.com/details?id=berserker.android.apps.sshdroid&#038;feature=search_result#?t=W251bGwsMSwxLDEsImJlcnNlcmtlci5hbmRyb2lkLmFwcHMuc3NoZHJvaWQiXQ.." title="SSHDroid" target="_blank">sshdroid</a>.</li>
<li>Download <a href="http://www.google.com.hk/url?sa=t&#038;rct=j&#038;q=putty&#038;source=web&#038;cd=1&#038;ved=0CCYQFjAA&#038;url=http%3A%2F%2Fwww.chiark.greenend.org.uk%2F~sgtatham%2Fputty%2Fdownload.html&#038;ei=E93gTujWJpGtiQemy6SXBQ&#038;usg=AFQjCNEawi7s0aRUeJP3qKnncgvPiSqZYA" title="putty" target="_blank">putty</a> and ssh to android (user root, password admin), executes the comment below<br />
<blockquote><p><code># busybox mkdir /system/xbin/bb<br />
# ln -s /system/xbin/busybox /system/xbin/bb/ifconfig<br />
# ln -s /system/xbin/busybox /system/xbin/bb/route<br />
</code></p></blockquote>
</li>
<li>Download <a href="http://blog.deadcode.net/downloads/4" title="tun.ko for android 2.3.6" target="_blank">tun.ko</a> and copy to android /system/modules</li>
<li>Go to market again and download <a href="https://market.android.com/details?id=de.schaeuffelhut.android.openvpn.installer&#038;feature=search_result" title="OpenVPN installer" target="_blank">openvpn installer</a> and <a href="https://market.android.com/details?id=de.schaeuffelhut.android.openvpn&#038;feature=search_result#?t=W251bGwsMSwxLDEsImRlLnNjaGFldWZmZWxodXQuYW5kcm9pZC5vcGVudnBuIl0." title="OpenVPN Setting" target="_blank">openvpn settings</a></li>
<li>Open OpenVPN Installer and click &#8216;Install&#8217; button.
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000008-180x300.png" alt="" title="Android OpenVPN Installer" width="180" height="300" class="alignnone size-medium wp-image-3346" />.</p>
<p>Click Install again to confirm installation.</p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000009-180x300.png" alt="" title="Android OpenVPN Installer: Confirm installation" width="180" height="300" class="alignnone size-medium wp-image-3347" /></p>
<p>Choose &#8216;/system/xbin&#8217;.</p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000011-180x300.png" alt="" title="Android OpenVPN Installer: Choose installation path" width="180" height="300" class="alignnone size-medium wp-image-3348" /></p>
<p>Keep clicking allow button to continue.</p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000013-180x300.png" alt="" title="Android OpenVPN Installer: grant root access for installer" width="180" height="300" class="alignnone size-medium wp-image-3349" />
</li>
<li>Open OpenVPN Settings, click Menu/Advanced
<p>- Click &#8216;Load tun kernel module&#8217;<br />
- Input &#8216;/sdcard/openvpn&#8217; as path to configurations<br />
- Input &#8216;/system/xbin/openvpn&#8217; as path to openvpn binary</p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000016-180x300.png" alt="" title="Android OpenVPN Setting: Advanced Setting" width="180" height="300" class="alignnone size-medium wp-image-3351" /></p>
<p>- Click &#8216;TUN module settings&#8217;, in &#8216;Load module using&#8217;, select &#8216;insmod&#8217; and input &#8216;/system/modules/tun.ko&#8217; as &#8216;path to tun module&#8217;.</p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000017-180x300.png" alt="" title="Android OpenVPN Setting: TUN module settings" width="180" height="300" class="alignnone size-medium wp-image-3352" /></p>
</li>
<li>Connect your phone with the usb cable, create a &#8216;openvpn&#8217; directory to the sdcard root. Copy the OpenVPN client config file i.e. client.ovpn, ca.crt, client.crt, client.key, ta.key to the /sdcard/openvpn directory.</li>
<li>Back to OpenVPN Setting, click OpenVPN to turn on OpenVPN. Long click the OpenVPN client config and then click Preferences from the popup menu.
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000019-180x300.png" alt="" title="Android OpenVPN Settings: OpenVPN Preferences" width="180" height="300" class="alignnone size-medium wp-image-3353" />
</li>
<li>Select &#8216;Built-in + Scripts (passwords)&#8217; for Script Security Level.
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/12/shot_000020-180x300.png" alt="" title="Android OpenVPN Settings: VPN Preferences" width="180" height="300" class="alignnone size-medium wp-image-3355" />
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/12/08/install-openvpn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Root Nexus S 2.3.6 &#8211; the perfect way</title>
		<link>http://blog.deadcode.net/2011/12/07/root-nexus-s/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=root-nexus-s</link>
		<comments>http://blog.deadcode.net/2011/12/07/root-nexus-s/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 21:06:06 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Nexus S]]></category>
		<category><![CDATA[Root]]></category>

		<guid isPermaLink="false">http://blog.deadcode.net/?p=3321</guid>
		<description><![CDATA[<p>Tested device: GRK39F I9023 Android vers: 2.3.6</p> <p>UPDATE 2012-04-05</p> <p>I just received OTA 4.0.4 update notification from my rooted nexus s </p> <p>DISCLAIMER</p> <p>Rooting a device requires RESETTING the phone. This will erase ALL EXISTING DATA on your phone&#8217;s memory, SD card and usb storage!</p> <p>Rooting also can brick your phone and void your [...]]]></description>
			<content:encoded><![CDATA[<p>Tested device: GRK39F I9023<br />
Android vers: 2.3.6</p>
<p><strong>UPDATE 2012-04-05</strong></p>
<p>I just received OTA 4.0.4 update notification from my rooted nexus s <img src='http://blog.deadcode.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>DISCLAIMER</strong></p>
<p>Rooting a device requires RESETTING the phone. This will erase ALL EXISTING DATA on your phone&#8217;s memory, SD card and usb storage!</p>
<p>Rooting also can brick your phone and void your warranty!</p>
<p>Make sure you backup everything before continue, you are warned.</p>
<p>Any downloads here is get from some android forum, I am not sure it is virus free.</p>
<p>Take your own risk. I&#8217;m not responsible for any loss following any steps below.</p>
<p>The steps here DO NOT FLASH CUSTOM RECOVERY, so it should not avoid google&#8217;s OTA update.</p>
<p><strong>UNLOCK BOOTLOADER</strong></p>
<ol>
<li>Download <a href="http://blog.deadcode.net/downloads/2" title="android debug bridge" target="_blank">adb4.zip</a> and extract adb folder to c:\	</li>
<li>Download and extract <a href="http://blog.deadcode.net/downloads/3" title="Nexus S Driver" target="_blank">Nexus_S_Drivers_x86_%26_x64.zip</a> to any folder</li>
<li>Download and copy <a href="http://blog.deadcode.net/downloads/1" title="su 2.3.6.1 ef signed" target="_blank">su-2.3.6.1-ef-signed.zip</a> to the root of the phone&#8217;s sd card</li>
<li>Setting / Application settings / Development
<p>Click USB debugging
</li>
<li>Switch off the phone. Keep pressing the volume up button without releasing it, at the same time switch on the phone.</li>
<li>Use volume button and navigate to the &#8216;Reboot Bootloader&#8217; option, then press the power button once.</li>
<li>Now connect the usb cable to the phone and the PC</li>
<li>When installing the driver to PC, select the folder where you extracted the Nexus_S_Drivers_x86_%26_x64.rar, install the driver to your PC.</li>
<li>double click the c:\adb\install-unlock.bat</li>
<li>Select &#8216;Yes&#8217; on your phone then press the power button once.</li>
<li>After reboot, then select &#8216;Reboot&#8217; and press the power button once again.</li>
</ol>
<p><strong>BACKUP NAND</strong></p>
<p>Before rooting the phone, it is better to backup the nand first.</p>
<ol>
<li>Disconnect the usb cable</li>
<li>Setting / Application settings / Development
<p>Click USB debugging
</li>
<li>Switch off the phone. Keep pressing the volume up button without releasing it, at the same time switch on the phone.</li>
<li>Use volume button and navigate to the &#8216;Reboot Bootloader&#8217; option, then press the power button once.</li>
<li>Now connect the usb cable to the phone and the PC</li>
<li>Double click the &#8216;c:\adb\install-fastboot-windows.bat&#8217;.</li>
<li>Select &#8216;Backup and restore&#8217;, then select &#8216;Backup&#8217;</li>
<li>After Backup, select &#8216;Reboot System Now&#8217;</li>
<li>
Connect the phone to PC using usb cable. Backup the sdcard:/clockworkmod/backup folder to your PC.
</li>
</ol>
<p><strong>ROOT THE PHONE</strong></p>
<ol>
<li>Disconnect the usb cable</li>
<li>Setting / Application settings / Development
<p>Click USB debugging
</li>
<li>Switch off the phone. Keep pressing the volume up button without releasing it, at the same time switch on the phone.</li>
<li>Use volume button and navigate to the &#8216;Reboot Bootloader&#8217; option, then press the power button once.</li>
<li>Now connect the usb cable to the phone and the PC</li>
<li>Double click the &#8216;c:\adb\install-fastboot-windows.bat&#8217;.</li>
<li>Select &#8216;Install zip from sdcard&#8217;</li>
<li>Select &#8216;Choose zip from sdcard&#8217;</li>
<li>Select the &#8216;su-2.3.6.1-ef-signed.zip&#8217; from the sdcard</li>
<li>After installed the su package, select &#8216;Reboot System Now&#8217;</li>
</ol>
<p><strong>Reference</strong></p>
<p><a href="http://www.mobile01.com/topicdetail.php?f=565&#038;t=2070033&#038;last=28330001" title="Mobile01 I9023 ROOT教學" target="_blank">Mobile01 &#8211; I9023 ROOT教學</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/12/07/root-nexus-s/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synology DS207+ modding series 34 &#8211; FreeRadius Accounting for OpenVPN with MySQL and daloRadius</title>
		<link>http://blog.deadcode.net/2011/11/26/freeradius-accounting-for-openvpn-with-mysql-and-daloradius/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=freeradius-accounting-for-openvpn-with-mysql-and-daloradius</link>
		<comments>http://blog.deadcode.net/2011/11/26/freeradius-accounting-for-openvpn-with-mysql-and-daloradius/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 20:58:08 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[daloRadius]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[FreeRadius]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[php-pear]]></category>
		<category><![CDATA[php-pear-db]]></category>
		<category><![CDATA[Radius Accounting]]></category>

		<guid isPermaLink="false">http://blog.deadcode.net/?p=3289</guid>
		<description><![CDATA[<p><strong>Prerequisite</strong></p>
<ol>
<li><a href="http://blog.deadcode.net/openvpn" target="_blank">Modding series 7 &#8211; Setup OpenVPN Server</a></li>
<li><a href="http://blog.deadcode.net/2009/11/11/install-freeradius-server-and-integrate-with-openldap-server/" target="_blank">Modding series 21 &#8211; Install FreeRadius Server</a></li>
<li><a href="http://blog.deadcode.net/2009/11/11/putting-it-all-together-openvpnfreeradiusopenldap/" target="_blank">Modding series 22 &#8211; Install FreeRadius plugin for OpenVPN</a></li>
</ol>
<p>I&#8217;m using daloRadius as accounting and reporting tools here. The management function is not used (except NAS client part).</p>
<p><strong>Install daloRadius</strong></p>
<p>Download daloRadius 0.9.9 package </p>
<blockquote><p><code># cd /volume1/web<br />
# wget http://downloads.sourceforge.net/project/daloradius/daloradius/daloradius0.9-9/daloradius-0.9-9.tar.gz<br />
# tar xvzf daloradius-0.9-9.tar.gz<br />
# rm daloradius-0.9-9.tar.gz<br />
# chown -R nobody:nobody /volume1/web/daloradius-0.9-9<br />
# chown 644 /volume1/web/daloradius-0.9-9/library/daloradius.conf.php<br />
</code></p></blockquote>
<p>Edit /volume1/web/daloradius-0.9-9/library/daloradius.conf.php, update the values as below</p>
<blockquote><p><code><br />
$configValues['CONFIG_DB_USER'] = 'radius';<br />
$configValues['CONFIG_DB_PASS'] = 'radpass';<br />
$configValues['CONFIG_DB_NAME'] = 'radiusdb';<br />
$configValues['CONFIG_FILE_RADIUS_PROXY'] = '/opt/etc/raddb/proxy.conf';<br />
$configValues['CONFIG_PATH_DALO_VARIABLE_DATA'] = '/opt/var/daloradius';<br />
$configValues['CONFIG_LOG_FILE'] = '/opt/var/log/daloradius.log';<br />
</code></p></blockquote>
<p>Follow up</p>
<blockquote><p><code><br />
# mkdir /opt/var/daloradius<br />
# chown nobody:nobody /opt/var/daloradius<br />
# touch /opt/var/log/daloradius.log<br />
# chown nobody:nobody /opt/var/log/daloradius.log<br />
</code></p></blockquote>
<p>Create and import the database</p>
<blockquote><p><code><br />
# /usr/syno/mysql/bin/mysql -u root -p</p>
<p>&gt; CREATE DATABASE radiusdb;<br />
&gt; GRANT ALL ON radiusdb.* TO radius@localhost IDENTIFIED BY "radpass";<br />
&gt; GRANT ALL ON radiusdb.* TO radius@127.0.0.1 IDENTIFIED BY "radpass";<br />
&gt; exit;</p>
<p># cd /volume1/web/daloradius-0.9-9/contrib/db<br />
# /usr/syno/mysql/bin/mysql -u radius -p radiusdb < fr2-mysql-daloradius-and-freeradius.sql<br />
# password: radpass<br />
</code></p></blockquote>
<p><strong>Install PHP extension</strong></p>
<p>Install php-pear and php-pear-db</p>
<blockquote><p><code># ipkg install php-pear<br />
# pear config-set php_bin /usr/bin/php<br />
# cd /opt/share/pear<br />
# wget http://download.pear.php.net/package/DB-1.7.14.tgz<br />
# mv DB-1.7.14.tgz DB.tgz<br />
# tar xvzf DB.tgz<br />
# chown -R nobody:nobody /opt/share/pear<br />
</code></p></blockquote>
<p>Edit php configuration</p>
<blockquote><p>
# vi /usr/syno/etc/php.ini</p>
<p>include_path = .:/php/includes:/opt/share/pear:/opt/share/pear/DB</p>
<p># vi /usr/syno/etc/php/user-setting.ini</p>
<p>append <strong>/opt/share/pear:/opt/share/pear/DB</strong> to open_basedir</p></blockquote>
<p>Install php-gd</p>
<blockquote><p># ipkg install php-gd</p></blockquote>
]]></description>
			<content:encoded><![CDATA[<p><strong>Prerequisite</strong></p>
<ol>
<li><a href="http://blog.deadcode.net/openvpn" target="_blank">Modding series 7 &#8211; Setup OpenVPN Server</a></li>
<li><a href="http://blog.deadcode.net/2009/11/11/install-freeradius-server-and-integrate-with-openldap-server/" target="_blank">Modding series 21 &#8211; Install FreeRadius Server</a></li>
<li><a href="http://blog.deadcode.net/2009/11/11/putting-it-all-together-openvpnfreeradiusopenldap/" target="_blank">Modding series 22 &#8211; Install FreeRadius plugin for OpenVPN</a></li>
</ol>
<p>I&#8217;m using daloRadius as accounting and reporting tools here. The management function is not used (except NAS client part).</p>
<p><strong>Install daloRadius</strong></p>
<p>Download daloRadius 0.9.9 package </p>
<blockquote><p><code># cd /volume1/web<br />
# wget http://downloads.sourceforge.net/project/daloradius/daloradius/daloradius0.9-9/daloradius-0.9-9.tar.gz<br />
# tar xvzf daloradius-0.9-9.tar.gz<br />
# rm daloradius-0.9-9.tar.gz<br />
# chown -R nobody:nobody /volume1/web/daloradius-0.9-9<br />
# chown 644 /volume1/web/daloradius-0.9-9/library/daloradius.conf.php<br />
</code></p></blockquote>
<p>Edit /volume1/web/daloradius-0.9-9/library/daloradius.conf.php, update the values as below</p>
<blockquote><p><code><br />
$configValues['CONFIG_DB_USER'] = 'radius';<br />
$configValues['CONFIG_DB_PASS'] = 'radpass';<br />
$configValues['CONFIG_DB_NAME'] = 'radiusdb';<br />
$configValues['CONFIG_FILE_RADIUS_PROXY'] = '/opt/etc/raddb/proxy.conf';<br />
$configValues['CONFIG_PATH_DALO_VARIABLE_DATA'] = '/opt/var/daloradius';<br />
$configValues['CONFIG_LOG_FILE'] = '/opt/var/log/daloradius.log';<br />
</code></p></blockquote>
<p>Follow up</p>
<blockquote><p><code><br />
# mkdir /opt/var/daloradius<br />
# chown nobody:nobody /opt/var/daloradius<br />
# touch /opt/var/log/daloradius.log<br />
# chown nobody:nobody /opt/var/log/daloradius.log<br />
</code></p></blockquote>
<p>Create and import the database</p>
<blockquote><p><code><br />
# /usr/syno/mysql/bin/mysql -u root -p</p>
<p>&gt; CREATE DATABASE radiusdb;<br />
&gt; GRANT ALL ON radiusdb.* TO radius@localhost IDENTIFIED BY "radpass";<br />
&gt; GRANT ALL ON radiusdb.* TO radius@127.0.0.1 IDENTIFIED BY "radpass";<br />
&gt; exit;</p>
<p># cd /volume1/web/daloradius-0.9-9/contrib/db<br />
# /usr/syno/mysql/bin/mysql -u radius -p radiusdb < fr2-mysql-daloradius-and-freeradius.sql<br />
# password: radpass<br />
</code></p></blockquote>
<p><strong>Install PHP extension</strong></p>
<p>Install php-pear and php-pear-db</p>
<blockquote><p><code># ipkg install php-pear<br />
# pear config-set php_bin /usr/bin/php<br />
# cd /opt/share/pear<br />
# wget http://download.pear.php.net/package/DB-1.7.14.tgz<br />
# mv DB-1.7.14.tgz DB.tgz<br />
# tar xvzf DB.tgz<br />
# chown -R nobody:nobody /opt/share/pear<br />
</code></p></blockquote>
<p>Edit php configuration</p>
<blockquote><p>
# vi /usr/syno/etc/php.ini</p>
<p>include_path = .:/php/includes:/opt/share/pear:/opt/share/pear/DB</p>
<p># vi /usr/syno/etc/php/user-setting.ini</p>
<p>append <strong>/opt/share/pear:/opt/share/pear/DB</strong> to open_basedir</p></blockquote>
<p>Install php-gd</p>
<blockquote><p># ipkg install php-gd</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/11/26/freeradius-accounting-for-openvpn-with-mysql-and-daloradius/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synology DS207+ modding series 33 &#8211; Install MOTP and integrate with FreeRadius</title>
		<link>http://blog.deadcode.net/2011/11/14/install-motp-with-freeradius/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-motp-with-freeradius</link>
		<comments>http://blog.deadcode.net/2011/11/14/install-motp-with-freeradius/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 17:42:04 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[FreeRadius]]></category>
		<category><![CDATA[Mobile-OTP]]></category>
		<category><![CDATA[MOTP]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[One-Time-Password]]></category>

		<guid isPermaLink="false">http://blog.deadcode.net/?p=3219</guid>
		<description><![CDATA[<p>MOTP stands for mobile one time password which provides one time password services.</p> <p>Download and install otp server</p> Login to DS as root mkdir -p /opt/usr/local/bin cd /opt/usr/local/bin Download otp server script <p># wget http://motp.sourceforge.net/bash/otpverify.sh Install necessary library <p># ipkg install findutils # ipkg install md5deep # ipkg install bash Edit otpverify.sh <p># vi [...]]]></description>
			<content:encoded><![CDATA[<p>MOTP stands for mobile one time password which provides one time password services.</p>
<p><strong>Download and install otp server</strong></p>
<ol>
<li>Login to DS as root</li>
<li>mkdir -p /opt/usr/local/bin</li>
<li>cd /opt/usr/local/bin</li>
<li>Download otp server script
<p># wget http://motp.sourceforge.net/bash/otpverify.sh</li>
<li>Install necessary library
<p># ipkg install findutils<br />
# ipkg install md5deep<br />
# ipkg install bash
</li>
<li>Edit otpverify.sh
<p># vi /opt/usr/local/bin/otpverify.sh</p>
<p>Changes highlighted in red.</p>
<blockquote><pre><code>
#!<font color=red>/opt/bin/bash</font>
#
# Mobile One Time Passwords (Mobile-OTP) for Java 2 Micro Edition, J2ME
# written by Matthias Straub, Heilbronn, Germany, 2003
# (c) 2003 by Matthias Straub
#
# Version 1.05a
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# arguments:  $1 $2 $3 $4 $5
# $1 - username
# $2 - one-time-password that is to be checked
# $3 - init-secred from token (to init token: #**#)
# $4 - user PIN
# $5 - time difference between token and server in 10s of seconds (360 = 1 hour)
#
# one-time-password must match md5(EPOCHTIME+SECRET+PIN)
# 

#
# otpverify.sh version 1.04b, Feb. 2003
# otpverify.sh version 1.04c, Nov. 2008
#  changed line 1 to ksh because of problems with todays bash an sh
# otpverify.sh version 1.05a, Jan. 2011
#  changed back to bash and added in shopts line to ensure aliases handled
#  correctly (bash is always available on any modern *nix unlike ksh)
#

PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin<font color=red>:/opt/usr/local/bin:/opt/bin:/opt/sbin</font>

# ensure aliases are expanded by bash
shopt -s expand_aliases

if [ -e "`which md5 2>/dev/null`" ]
then
	alias checksum=md5
	have_md5="true"
fi
if [ -e "`which md5sum 2>/dev/null`" ]
then
	alias checksum=md5sum
	have_md5="true"
fi

<font color=red>
alias checksum=md5deep
have_md5="true"
</font>

if [ $have_md5 != "true" ]
then
	echo "No md5 or md5sum available on server!"
	<font color=red>exit 16</font>
fi

function chop
{
	num=`echo -n "$1" | wc -c | sed 's/ //g' `
	nummin1=`expr $num "-" 1`
	echo -n "$1" | cut -b 1-$nummin1
}

if [ ! $# -eq 5 ] ; then
echo "USAGE: otpverify.sh Username, OTP, Init-Secret, PIN, Offset"
<font color=red>exit 14</font>
fi

mkdir <font color=red>/opt/var/motp</font> 2>/dev/null
mkdir <font color=red>/opt/var/motp/cache</font> 2>/dev/null
mkdir <font color=red>/opt/var/motp/users</font> 2>/dev/null
chmod og-rxw <font color=red>/opt/var/motp</font> 2>/dev/null || { echo "FAIL! Need write-access to <font color=red>/opt/var/motp</font>"; <font color=red>exit 17</font>; }
chmod og-rxw <font color=red>/opt/var/motp/cache</font>
chmod og-rxw <font color=red>/opt/var/motp/users</font>

USERNAME=`echo -n "$1" | sed 's/[^0-9a-zA-Z._-]/X/g' `
PASSWD=`echo -n "$2" | sed 's/[^0-9a-f]/0/g' `
SECRET=`echo -n "$3" | sed 's/[^0-9a-f]/0/g' `
PIN=`echo -n "$4" | sed 's/[^0-9]/0/g' `
OFFSET=`echo -n "$5" | sed 's/[^0-9]/0/g' `
EPOCHTIME=`date +%s` ; EPOCHTIME=`chop $EPOCHTIME`

# delete old logins
<font color=red>/opt/bin/find /opt/var/motp/cache</font> -type f -cmin +5 | xargs rm 2>/dev/null

if [ -e "<font color=red>/opt/var/motp/cache/$PASSWD</font>" ]; then
	echo "FAIL"
	<font color=red>exit 15</font>
fi

# account locked?
if [ "`cat <font color=red>/opt/var/motp/users/$USERNAME</font> 2>/dev/null`" == "8" ]; then
	echo "FAIL"
	<font color=red>exit 13</font>
fi

I=0
EPOCHTIME=`expr $EPOCHTIME - 18`
EPOCHTIME=`expr $EPOCHTIME + $OFFSET`
while [ $I -lt 36 ] ; do # 3 minutes before and after
	OTP=`printf $EPOCHTIME$SECRET$PIN|checksum|cut -b 1-6`
	if [ "$OTP" = "$PASSWD" ] ; then
		/bin/touch <font color=red>/opt/var/motp/cache/$OTP</font> || { echo "FAIL! Need write-access to <font color=red>/opt/var/motp</font>" ; <font color=red>exit 17</font>; }
		echo "ACCEPT"
		rm "<font color=red>/opt/var/motp/users/$USERNAME</font>" 2>/dev/null
		exit 0
	fi
	I=`expr $I + 1`
	EPOCHTIME=`expr $EPOCHTIME + 1`
done

echo "FAIL"
NUMFAILS=`cat "<font color=red>/opt/var/motp/users/$USERNAME</font>" 2>/dev/null`
if [ "$NUMFAILS" = "" ]; then
	NUMFAILS=0
fi
NUMFAILS=`expr $NUMFAILS + 1`
echo $NUMFAILS > "<font color=red>/opt/var/motp/users/$USERNAME</font>"
<font color=red>exit 11</font>
</code></pre>
</blockquote>
<p>In case there is a newer version of this server script released in the future, here is the summary of changes:</p>
<ul>
<li>line 1 should point to optware bash: /opt/bin/bash</li>
<li>The script will only looks for md5 and md5sum binary, however, we are using md5deep from optware instead. Add two lines to assign md5deep as checksum binary.</li>
<li>Add 10 to all error code, otherwise it will fail the FreeRadius server</li>
<li>Basically I&#8217;ve appended /opt to every path inside the script.</li>
<li>It need the <strong>find </strong> binary. We should use the binary provided by optware instead of using the system default binary.</li>
</ul>
</li>
<li># chmod 755 /opt/usr/local/bin/otpverify.sh</li>
</ol>
<p><strong>Download and setup Android motp client</strong></p>
<p>Since I&#8217;ve an Android phone, I install the motp client to my phone.</p>
<ol>
<li>Download the android motp client &#8216;Mobile-OTP&#8217; from url below
<p>http://motp.sourceforge.net/Mobile-OTP.apk</li>
<li>Install the apk to the phone</li>
<li>Run the Mobile-OTP.</li>
<li>Input #**# and click &#8216;Calculate OTP&#8217; button. An init-secret value will be generated. Copy the <strong>init-secret</strong> and paste it to somewhere, i.e. notepad.</li>
<li>Input 1234 and click &#8216;Calculate OTP&#8217; button again. An <strong>one time password</strong> will be generated.</li>
<li>Now test the setup, SSH to the DiskStation as root and run the command as below:<br />
<blockquote><p><code><br />
# /opt/usr/local/bin/otpverify.sh testuser [<strong>one-time-password</strong>] [<strong>Init-secret</strong>] 1234 0<br />
</code></p></blockquote>
<p>If you run the command fast enough, the script should return &#8220;ACCEPT&#8221;. If you got a &#8220;FAIL&#8221;, repeats again by generating a new one-time-password and execute the command again couple times until you got &#8220;ACCEPT&#8221;. Make sure the Init-secret and One-time-password is input correctly.
</li>
</ol>
<p><strong>FreeRadius changes</strong></p>
<ol>
<li>SSH to DS as root</li>
<li># cd /opt/etc/raddb</li>
<li># wget http://motp.sourceforge.net/dictionary.motp</li>
<li>Edit /opt/etc/raddb/dictionary, add following line to the end of the file
<p>$INCLUDE dictionary.motp</li>
<li>Although I don&#8217;t think this step is needed, but it is suggested by the official installation guide.<br />
# wget http://motp.sourceforge.net/execparams</li>
<li>Add a test user by editing /opt/etc/raddb/users file. Add following lines to the end of the file.<br />
<blockquote><pre><code>
testuser Auth-Type = Accept
    Exec-Program-Wait = "/opt/usr/local/bin/otpverify.sh %{User-Name} %{User-Password} <font color=red>123412341234 1234</font> 0",
    Fall-Through = Yes,
    Reply-Message = "Hello, %{User-Name}"
</code></pre>
</blockquote>
<p>where 123412341234 is the init-secret and 1234 is the pin of the test user. Replace the value of init-secret with the one generated by the Android OTP client.
</li>
<li>Generate a new One-time-password using the Android OTP client (input 1234 and click &#8216;Calculate OTP&#8217; button), then test the freeradius setup by executing the command below:<br />
<blockquote><p><code><br />
#  radtest testuser [one-time-password] localhost 0 [FreeRadius shared secret password]<br />
</code></p></blockquote>
<p>If success, you should got a response similar to below:</p>
<blockquote><p><code><br />
rad_recv: <font color=red>Access-Accept</font> packet from host 127.0.0.1 port 1812, id=48, length=46<br />
        Reply-Message = "Hello, testuser  "<br />
</code></p></blockquote>
</li>
</ol>
<p>Now my services like OpenVPN and Squid  accept OTP login <img src='http://blog.deadcode.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://motp.sourceforge.net" title="Mobile OTP" target="_blank">Mobile-OTP</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/11/14/install-motp-with-freeradius/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Synology modding series 32 &#8211; Setup Wifi WPA2 Enterprise with Freeradius+Openldap/Client Certificate</title>
		<link>http://blog.deadcode.net/2011/11/13/setup-wifi-wpa2-enterprise-with-freeradiusopenldap/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setup-wifi-wpa2-enterprise-with-freeradiusopenldap</link>
		<comments>http://blog.deadcode.net/2011/11/13/setup-wifi-wpa2-enterprise-with-freeradiusopenldap/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 16:02:05 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[FreeRadius]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[OpenLDAP]]></category>
		<category><![CDATA[Wifi]]></category>
		<category><![CDATA[WPA2 Enterprise]]></category>

		<guid isPermaLink="false">http://blog.deadcode.net/?p=3177</guid>
		<description><![CDATA[<p><strong>Prerequisite</strong></p>
<ol>
<li><a href="http://blog.deadcode.net/2009/05/23/setup-openldap-on-ds207/" target="_blank">Modding series 9 &#8211; Setup an OpenLDAP Server</a></li>
<li><a href="http://blog.deadcode.net/2009/11/11/install-freeradius-server-and-integrate-with-openldap-server/" target="_blank">Modding series 21 &#8211; Install FreeRadius Server and integrate with OpenLDAP Server</a></li>
</ol>
<p><strong>Setup FreeRadius to support EAP-PEAP-TLS</strong></p>
<ol>
<li>SSH to DS as root</li>
<li>Edit /opt/etc/raddb/radiusd.conf, add following line to the config file
<p>$INCLUDE ${confdir}/sites-enabled/</p>
<blockquote><p><code><br />
# vi /opt/etc/raddb/radiusd.conf</p>
<p># <strong>add </strong> sites-enabled to the config<br />
$INCLUDE ${confdir}/sites-enabled/</p>
<p></code></p></blockquote>
</li>
<li>Edit /opt/etc/raddb/radiusd.conf again, looks for the authenticate section and then add mschap within the section.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/radiusd.conf

authenticate {
 .
 .
 .
  # add mschap
  mschap
}
</code></pre>
</blockquote>
<p>Looks for modules section and add three lines within modules section as below</p>
<blockquote><pre><code>
# vi /opt/etc/raddb/radiusd.conf

modules {
 # add expiration, logintime and attr_filter modules
 $INCLUDE ${confdir}/modules/expiration
 $INCLUDE ${confdir}/modules/logintime
 $INCLUDE ${confdir}/modules/attr_filter

}
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/eap.conf, change default_eap_type to peap.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/eap.conf

.
.
default_eap_type = peap
.
.
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/sites-enabled/default, looks for authorize section and un-comment the ldap line.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/default

authorize {
.
.
# un-comment the ldap
 ldap
.
.
}
</code></pre>
</blockquote>
<p>Then looks for authenticate section and uncomment Auth-Type LDAP as well.</p>
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/default

authenticate {
.
.
# un-comment the ldap
 Auth-Type LDAP{
     ldap
 }
.
.
}
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/sites-enabled/inner-tunnel, looks for authorize section and un-comment the ldap line.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/inner-tunnel

authorize {
.
.
# un-comment the ldap
 ldap
.
.
}
</code></pre>
</blockquote>
<p>Then looks for authenticate section and uncomment Auth-Type LDAP as well.</p>
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/inner-tunnel

authenticate {
.
.
# un-comment the ldap
 Auth-Type LDAP{
     ldap
 }
.
.
}
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/clients.conf, add the Wifi Access Point to the config file.<br />
<blockquote><p><code><br />
# vi /opt/etc/raddb/clients.conf</p>
<p># add access point details here, 192.168.0.1 is the ip of the access point</p>
<pre>
client 192.168.0.1 {
     secret = [shared secret password of radius server]
     shortname = [SSID of the access point]
     nastype = other
}
</pre>
<p></code></p></blockquote>
</li>
<li>If you have firewall activate on your diskstation, make sure to add a firewall rule to allow the wifi access point to access the udp port 1812, 1813 and 1814.</li>
</ol>
<p>For now the radius server is already able to perform authentication for wpa/wpa2 enterprise!</p>
<p><strong>Generate client certificate</strong></p>
<p>If you do not plan to perform authorization using client certificate, you can skip this part.</p>
<ol>
<li>SSH to DS as root</li>
<li>Edit /opt/etc/raddb/certs/client.cnf, refer to modding series 21 for details about this client certificate config file.
<p>** IMPORTANT The Country Name, State and Organization Name MUST match the value of the CA.
</li>
<li>Before we generate the client certificate, we MUST backup the original certificate first.<br />
<blockquote><p><code><br />
# cd /opt/etc/raddb<br />
# cp -r certs certs.b4genclient<br />
</code></p></blockquote>
</li>
<li>Generate a client certificate<br />
<blockquote><p><code><br />
# cd /opt/etc/raddb/certs<br />
# make client.pem</li>
<p></code></p></blockquote>
</li>
<li>If you want to generate another client certificate for other wifi client. Edit the client.cnf and run make client.pem again. If  make failed and said it couldn&#8217;t load a certificate, just copy the server.crt from backup directory and try again.<br />
<blockquote><p><code><br />
# cp /opt/etc/raddb/certs.b4genclient/server.crt /opt/etc/raddb/certs<br />
# make client.pem<br />
</code></p></blockquote>
</li>
</ol>
]]></description>
			<content:encoded><![CDATA[<p><strong>Prerequisite</strong></p>
<ol>
<li><a href="http://blog.deadcode.net/2009/05/23/setup-openldap-on-ds207/" target="_blank">Modding series 9 &#8211; Setup an OpenLDAP Server</a></li>
<li><a href="http://blog.deadcode.net/2009/11/11/install-freeradius-server-and-integrate-with-openldap-server/" target="_blank">Modding series 21 &#8211; Install FreeRadius Server and integrate with OpenLDAP Server</a></li>
</ol>
<p><strong>Setup FreeRadius to support EAP-PEAP-TLS</strong></p>
<ol>
<li>SSH to DS as root</li>
<li>Edit /opt/etc/raddb/radiusd.conf, add following line to the config file
<p>$INCLUDE ${confdir}/sites-enabled/</p>
<blockquote><p><code><br />
# vi /opt/etc/raddb/radiusd.conf</p>
<p># <strong>add </strong> sites-enabled to the config<br />
$INCLUDE ${confdir}/sites-enabled/</p>
<p></code></p></blockquote>
</li>
<li>Edit /opt/etc/raddb/radiusd.conf again, looks for the authenticate section and then add mschap within the section.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/radiusd.conf

authenticate {
 .
 .
 .
  # add mschap
  mschap
}
</code></pre>
</blockquote>
<p>Looks for modules section and add three lines within modules section as below</p>
<blockquote><pre><code>
# vi /opt/etc/raddb/radiusd.conf

modules {
 # add expiration, logintime and attr_filter modules
 $INCLUDE ${confdir}/modules/expiration
 $INCLUDE ${confdir}/modules/logintime
 $INCLUDE ${confdir}/modules/attr_filter

}
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/eap.conf, change default_eap_type to peap.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/eap.conf

.
.
default_eap_type = peap
.
.
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/sites-enabled/default, looks for authorize section and un-comment the ldap line.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/default

authorize {
.
.
# un-comment the ldap
 ldap
.
.
}
</code></pre>
</blockquote>
<p>Then looks for authenticate section and uncomment Auth-Type LDAP as well.</p>
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/default

authenticate {
.
.
# un-comment the ldap
 Auth-Type LDAP{
     ldap
 }
.
.
}
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/sites-enabled/inner-tunnel, looks for authorize section and un-comment the ldap line.<br />
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/inner-tunnel

authorize {
.
.
# un-comment the ldap
 ldap
.
.
}
</code></pre>
</blockquote>
<p>Then looks for authenticate section and uncomment Auth-Type LDAP as well.</p>
<blockquote><pre><code>
# vi /opt/etc/raddb/sites-enabled/inner-tunnel

authenticate {
.
.
# un-comment the ldap
 Auth-Type LDAP{
     ldap
 }
.
.
}
</code></pre>
</blockquote>
</li>
<li>Edit /opt/etc/raddb/clients.conf, add the Wifi Access Point to the config file.<br />
<blockquote><p><code><br />
# vi /opt/etc/raddb/clients.conf</p>
<p># add access point details here, 192.168.0.1 is the ip of the access point</p>
<pre>
client 192.168.0.1 {
     secret = [shared secret password of radius server]
     shortname = [SSID of the access point]
     nastype = other
}
</pre>
<p></code></p></blockquote>
</li>
<li>If you have firewall activate on your diskstation, make sure to add a firewall rule to allow the wifi access point to access the udp port 1812, 1813 and 1814.</li>
</ol>
<p>For now the radius server is already able to perform authentication for wpa/wpa2 enterprise!</p>
<p><strong>Generate client certificate</strong></p>
<p>If you do not plan to perform authorization using client certificate, you can skip this part.</p>
<ol>
<li>SSH to DS as root</li>
<li>Edit /opt/etc/raddb/certs/client.cnf, refer to modding series 21 for details about this client certificate config file.
<p>** IMPORTANT The Country Name, State and Organization Name MUST match the value of the CA.
</li>
<li>Before we generate the client certificate, we MUST backup the original certificate first.<br />
<blockquote><p><code><br />
# cd /opt/etc/raddb<br />
# cp -r certs certs.b4genclient<br />
</code></p></blockquote>
</li>
<li>Generate a client certificate<br />
<blockquote><p><code><br />
# cd /opt/etc/raddb/certs<br />
# make client.pem</li>
<p></code></p></blockquote>
</li>
<li>If you want to generate another client certificate for other wifi client. Edit the client.cnf and run make client.pem again. If  make failed and said it couldn&#8217;t load a certificate, just copy the server.crt from backup directory and try again.<br />
<blockquote><p><code><br />
# cp /opt/etc/raddb/certs.b4genclient/server.crt /opt/etc/raddb/certs<br />
# make client.pem<br />
</code></p></blockquote>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/11/13/setup-wifi-wpa2-enterprise-with-freeradiusopenldap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synology modding series 31 – Capturing Tomato Router Logs using syslog-ng</title>
		<link>http://blog.deadcode.net/2011/08/27/capturing-tomato-router-logs-using-syslog-ng/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=capturing-tomato-router-logs-using-syslog-ng</link>
		<comments>http://blog.deadcode.net/2011/08/27/capturing-tomato-router-logs-using-syslog-ng/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 09:25:45 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[syslog-ng]]></category>
		<category><![CDATA[tomato]]></category>

		<guid isPermaLink="false">http://blog.deadcode.net/?p=3102</guid>
		<description><![CDATA[<p>Since NAS is running 24&#215;7, it is the best device to capture my tomato router logs.</p> <p>Install and Setup Syslog-ng</p> Login to NAS using ssh/telnet as root install syslog-ng <p>#ipkg install syslog-ng</p> <p>The glib and eventlog packages should be installed by ipkg as well. Backup syslog-ng configuration <p>#cd /opt/etc/syslog-ng #mv syslog-ng.conf syslog-ng.conf.bak Create configuration [...]]]></description>
			<content:encoded><![CDATA[<p>Since NAS is running 24&#215;7, it is the best device to capture my tomato router logs.</p>
<p><strong>Install and Setup Syslog-ng</strong></p>
<ol>
<li>Login to NAS using ssh/telnet as root</li>
<li>install syslog-ng
<p>#ipkg install syslog-ng</p>
<p>The glib and eventlog packages should be installed by ipkg as well. </li>
<li>Backup syslog-ng configuration
<p>#cd /opt/etc/syslog-ng<br />
#mv syslog-ng.conf syslog-ng.conf.bak
</li>
<li>Create configuration file
<p># vi /opt/etc/syslog-ng.conf</p>
<p>Below is my syslog-ng configuration to capture only the tomato router log</p>
<blockquote><p><code><br />
options { long_hostnames(off); sync(0); };</p>
<p>source src{<br />
            internal();<br />
            udp(port(<font color=red>5140</font>));<br />
};</p>
<p>destination tomatolog { file("/opt/var/log/tomato.log"); };</p>
<p>log {<br />
       source(src); destination(wrt54glog);<br />
};<br />
</code></p></blockquote>
<p>I&#8217;m using 5140 udp port, change to your own preferred port.
</li>
<li>Run the syslog-ng server
<p># /opt/etc/init.d/S01syslog-ng start
</li>
<li>If you have enabled the NAS firewall, you need to insert a firewall rule to allow the inbound logging traffic from the tomato router.
<p>Open a browser and go to the NAS control panel. Navigate to Control Panel / Firewall section. Click &#8216;Create&#8217; button to create a new firewall rule.</p>
<p><strong>Ports:</strong><br />
Custom Port Type: Destination port<br />
Protocol: UDP<br />
Ports: 5140</p>
<p><strong>Source IP</strong><br />
IP address: [IP address of tomato router, i.e. 192.168.1.1]</p>
<p><strong>Action</strong><br />
Allow</p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/08/nas-firewall-syslog-customport-5140-udp-300x140.jpg" alt="" title="NAS Firewall Rules : syslog-ng : 5140 : udp" width="300" height="140" class="alignnone size-medium wp-image-3104" /></p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/08/nas-firewall-syslog-sourceip-action-300x202.jpg" alt="" title="NAS Firewall Rules : syslog-ng : source ip : action" width="300" height="202" class="alignnone size-medium wp-image-3105" /></li>
</ol>
<p><strong>Setup Tomato Router</strong></p>
<ol>
<li>Open a browser and go to tomato admin page</li>
<li>Navigate to Administration / Logging page</li>
<li>Unclick the &#8216;Log Internally&#8217;<br />
Click the &#8216;Log To Remote System&#8217;<br />
Input the NAS IP address and syslog-ng port (which is 5140 defined in the syslog-ng.conf file)<br />
Choose the event(s) you want to capture.<br />
Input &#8217;0&#8242; in the limit textbox.<br />
Click &#8216;Save&#8217; button.</p>
<p><img src="http://blog.deadcode.net/wp-content/uploads/2011/08/tomato-syslog-config.jpg" alt="" title="Tomato remote logging configuration" width="495" height="414" class="alignnone size-full wp-image-3103" />
</li>
</ol>
<p>The router log is configured to /opt/var/log/tomato.log.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/08/27/capturing-tomato-router-logs-using-syslog-ng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synology modding series 30 &#8211; Integrate Squid with Freeradius</title>
		<link>http://blog.deadcode.net/2011/06/18/integrate-squid-with-freeradius/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=integrate-squid-with-freeradius</link>
		<comments>http://blog.deadcode.net/2011/06/18/integrate-squid-with-freeradius/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 15:58:55 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[FreeRadius]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://blog.deadcode.net/?p=3001</guid>
		<description><![CDATA[<p>In previous article I setup Squid and using a passwd file to hold password for squid. But now I have freeradius running, I want to integrate Squid with Freeradius so that I don&#8217;t need to maintain the passwd file.</p> <p>Luckily, the Squid compiled by optware already include basic-auth-helper option during compilation, what we need [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blog.deadcode.net/2009/05/11/setup-squid-http-proxy-server/" target=_new>previous article</a> I setup Squid and using a  passwd file to hold password for squid. But now I have <a href="http://blog.deadcode.net/2009/11/11/install-freeradius-server-and-integrate-with-openldap-server/" target=_new>freeradius</a> running, I want to integrate Squid with Freeradius so that I don&#8217;t need to maintain the passwd file.</p>
<p>Luckily, the Squid compiled by optware already include basic-auth-helper option during compilation, what we need to do is compile our own radius plugin.</p>
<p><strong>Pre-requisites</strong></p>
<ul>
<li>ipkg install make</li>
<li>ipkg install gcc</li>
</ul>
<p><strong>Installation<br />
</strong></p>
<ol>
<li>SSH to NAS as root</li>
<li>cd /root</li>
<li>Download the plugin source from squid officail site
<p># wget http://www.squid-cache.org/contrib/squid_radius_auth/squid_radius_auth-1.10.tar.gz</li>
<li>Unpack it
<p># tar xvzf squid_radius_auth-1.10.tar.gz</li>
<li># cd squid_radius_auth-1.10/</li>
<li>Build the plugin by typing make. (you need to install make if not already do so &#8211; ipkg install make)
<p># make</li>
<li>The plugin squid_radius_auth binary will be created here
<p>/root/squid_radius_auth-1.10/squid_radius_auth</li>
<li>Move the plugin to better directory
<p># mv /root/squid_radius_auth-1.10/squid_radius_auth /opt/libexec</li>
<li>Edit squid configuration
<p># vi /opt/etc/squid/squid.conf</p>
<p>Comment the ncsa_auth helper and add radius helper</p>
<p>#auth_param basic program /opt/libexec/ncsa_auth /opt/etc/passwd<br />
auth_param basic program /opt/libexec/squid_radius_auth -f /opt/etc/squid/squid_radius_auth.conf</li>
<li>Create the plugin configuration file
<p># vi /opt/etc/squid/squid_radius_auth.conf</p>
<p>Add the two lines below</p>
<p>server 127.0.0.1<br />
secret <font color=red>sharedsecret</font></p>
<p>(change sharedsecret to your radius server shared secret password)</li>
<li>Restart Squid
<p># /opt/etc/init.d/S80squid stop<br />
# /opt/etc/init.d/S80squid start
</li>
</ol>
<p>As well as <a href="http://blog.deadcode.net/2009/11/11/putting-it-all-together-openvpnfreeradiusopenldap/" target=_new>openvpn</a>, I also have squid integrated with freeradius and using openldap as the only password store.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/06/18/integrate-squid-with-freeradius/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synology usage series 0 &#8211; Installing DiskStation and Bootstrapping</title>
		<link>http://blog.deadcode.net/2011/05/31/installing-disk-station-and-bootstrapping-the-box/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-disk-station-and-bootstrapping-the-box</link>
		<comments>http://blog.deadcode.net/2011/05/31/installing-disk-station-and-bootstrapping-the-box/#comments</comments>
		<pubDate>Tue, 31 May 2011 03:35:27 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[NAS]]></category>

		<guid isPermaLink="false">http://deadcode.net/?p=2681</guid>
		<description><![CDATA[<p>This article records all my steps to install disk station with new hard disk and procedures of bootstrapping the box.</p> <p>Installing Disk Station</p> <p>My hard disk is WD2003FYYS-02W0B. Firware: DSM 3.1-1613 (claimed to be the last firmware available for 207 model.)</p> Downlod Synology Assistant and latest firmware 3.1-1613 from synology.com Install Synology Assistant on [...]]]></description>
			<content:encoded><![CDATA[<p>This article records all my steps to install disk station with new hard disk and procedures of bootstrapping the box.</p>
<p><strong>Installing Disk Station</strong></p>
<p>My hard disk is WD2003FYYS-02W0B.<br />
Firware: DSM 3.1-1613 (claimed to be the last firmware available for 207 model.)</p>
<ol>
<li>Downlod Synology Assistant and latest firmware 3.1-1613 from synology.com</li>
<li>Install Synology Assistant on PC</li>
<li>Insert the new hard disk to Diskstation and power on</li>
<li>Connect the DiskStation to the PC directly using LAN cable, not via router</li>
<li>Change the IP address of the PC to 169.254.116.1, subnet mask 255.255.255.0</li>
<li>Run Synology Assistant to install the firmware to the new drive. Select DSM_DS207+_1613.pat from firmware option.</li>
<li>Once setup completed, the DSM can be accessed by web browser using URL below:
<p>http://169.254.116.94:5000</p>
<p>username: admin<br />
password: [empty]</p>
<p>(noted: I&#8217;m not sure if Syno Assistant assigned the same IP 169.254.116.94 to the diskstation for every setup. It might be changed for your case.)</p>
</li>
<li>Setup the new hard disk from Storage Manager.
<p>Storage Manager &gt; Volume </p>
<p>Click &#8216;Create&#8217; button to create a new volume.</li>
</ol>
<p><strong>Boostrapping the box</strong></p>
<ol>
<li>Make sure the DS is connected to internet.</li>
<li>Telnet to DS and login as root. Password is same as admin. If telnet cannot connected to the DS, try turn off the firewall first.</li>
<li>Change directory to any smb share, for example, the public share
<p># cd /volume1/public
</li>
<li>Download the bootstrap script as below
<p># wget http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/syno-x07-bootstrap_1.2-7_arm.xsh</li>
<li>Start bootstrapping
<p># sh syno-x07-bootstrap_1.2-7_arm.xsh
</li>
<li>Add the following line to ipkg.conf, <strong>BEFORE</strong> the line &#8216;DEST root /&#8217;.<br />
<blockquote><p>
<strong>src packages http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/</strong>
</p></blockquote>
<p><strong>IMPORTANT</strong>:</p>
<p>ipkg will NOT work if the line above is placed after &#8216;DEST root /&#8217; </p>
</li>
<li>Update ipkg list
<p>#  ipkg update
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/05/31/installing-disk-station-and-bootstrapping-the-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synology modding series 29 – Restricting WordPress accessible by home dynamic ip only</title>
		<link>http://blog.deadcode.net/2011/05/19/restricting-wordpess-access-by-home-ip/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=restricting-wordpess-access-by-home-ip</link>
		<comments>http://blog.deadcode.net/2011/05/19/restricting-wordpess-access-by-home-ip/#comments</comments>
		<pubDate>Thu, 19 May 2011 07:50:32 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[Home IP]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[Restrict Access]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://deadcode.net/?p=2656</guid>
		<description><![CDATA[<p>Update Aug 22 2011</p> <p>The solution is redesigned so that the htaccess file is pushing from NAS to web hosting account. This greatly simplifed the overall process and resolved the deadlock situation.</p> <p>I have a few private wordpress blog hosting on some web hosting provider and want to protect my private blog to be [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>Update Aug 22 2011</strong></p>
<p>The solution is redesigned so that the htaccess file is pushing from NAS to web hosting account. This greatly simplifed the overall process and resolved the deadlock situation.</p></blockquote>
<p>I have a few private wordpress blog hosting on some web hosting provider and want to protect my private blog to be accessible only by home dynamic ip address. </p>
<p>This require rewriting htaccess file on web hosting account for every ip changes.</p>
<p>This may not related to Synology, but I need the help of DS207+ in order to perform the job by some automated scripts.</p>
<p><strong>Solution</strong></p>
<p>Firstly, a perl script sync-htaccess.pl is required to host on the NAS.</p>
<p>The script will</p>
<ol>
<li>Get External IP address of the NAS by calling the getip.php hosting on web hosting account</li>
<li>Read the htaccess template, find the line @@@DYNAMIC@@@ and replace the line with &#8216;allow from 1.2.3.4&#8242; (where 1.2.3.4 is the external IP address returned by getip.php)</li>
<li>Write the actual .htaccess files to temporary directory.</li>
<li>Upload the actual .htaccess files to web hosting account by synchronizing the temporary directory to the web hosting account. (using rsync over ssh)</li>
</ol>
<p>The reason I am using rsync over ssh instead of scp/sftp to upload files because rsync and ssh is already provided by Synology, no addition ipkg package is required.</p>
<p>So, go ahead to create the perl script to /opt/usr/local/bin/sync-htaccess.pl</p>
<blockquote><p>
<code><br />
#!/usr/bin/perl</p>
<p># v0.4<br />
#	Aug 22 2011<br />
#		Modified to run at NAS instead of webhost<br />
# v0.31<br />
#	May 15 2011<br />
#		Add timeout and retries flag to wget command to prevent infinite lookup<br />
# v0.3<br />
# 	May 14 2011<br />
#		host not returning ip address, using wget instead<br />
# v0.2<br />
# 	May 3 2011<br />
#		Fix the host command to query type A record only</p>
<p>$version="0.4";</p>
<p>print "Executing sync-htaccess.pl version=$version\n";</p>
<p>##################################<br />
### configuration begin here ###</p>
<p># define sub domain 1<br />
$site1output="/opt/tmp/sync-htaccess/.htaccess";<br />
$site1template = "/opt/etc/sync/blog_htaccess_template";</p>
<p># if you have more sub domain, copy the two lines and paste here<br />
#$siteXXXoutput = "/opt/tmp/sync-htaccess/XXX/.htaccess";<br />
#$siteXXXtemplate = "/opt/etc/sync/xxx_htaccess_template";</p>
<p>$logfile  = "/opt/var/log/rsync-htaccess.log";<br />
$sshkey   = "/volume1/private/id_rsa";<br />
$sshport  = "22";<br />
$source   = "/opt/tmp/sync-htaccess/";<br />
$remote   = "/home/account/public_html";</p>
<p>$getipurl = "http://www.mydomain/getip.php";<br />
$accid    = "account_id";<br />
$accdomain= "mydomain.com";</p>
<p>### END of CONFIGURATION, DO NOT MODIFY BELOW ####<br />
##################################################</p>
<p># get ip address<br />
$ip=`wget --timeout=10 --tries=1 -qO -  $getipurl | sed 's/^ *\(.*\) *\$/\1/'`;</p>
<p>print "ip address $ip\n";</p>
<p># write to output file, if you have more subdomain, duplicate the line below and modified the variables<br />
writeHtaccess($ip,$site1template,$site1output);</p>
<p># upload to webhosting<br />
system("/usr/syno/bin/rsync -avz --log-file=$logfile -e 'ssh -i $sshkey -p $sshport' $source $accid\@$accdomain:$remote");</p>
<p>print "done\n";</p>
<p>sub writeHtaccess{<br />
	my ($myip,$mytemplate,$myhtaccess) = @_;</p>
<p>	open(TEMPLATE, $mytemplate) || die("Could not open file!");<br />
	@raw_data=<TEMPLATE>;<br />
	close(TEMPLATE);</p>
<p>	print "Writing to $myhtaccess\n";<br />
	open(NEW, ">$myhtaccess") || die("Could not create file!");</p>
<p>	foreach $line (@raw_data){<br />
		if($line =~ /\@\@\@DYNAMIC\@\@\@/){<br />
			if($myip eq ''){<br />
				print "Skipping home ip\n";<br />
			}else{<br />
				print NEW "allow from $myip\n";<br />
			}<br />
		}else{<br />
			print NEW $line;<br />
		}<br />
	}</p>
<p>	close(NEW);<br />
}<br />
</code>
</p></blockquote>
<p>To define the location of the htaccess template </p>
<blockquote><p><code><br />
$site1template = "/opt/etc/sync/blog_htaccess_template";<br />
</code></p></blockquote>
<p>The script will read the template above, finding the word &#8216;@@@DYNAMIC@@@&#8217; and replace the line by &#8216;allow from 1.2.3.4.&#8217; where 1.2.3.4 will be the home ip provided by the giveip.php script.</p>
<p>To define the URL of the giveip.php script</p>
<blockquote><p><code>$getipurl = "http://www.mydomain/getip.php";</code></p></blockquote>
<p>After parsing, the script will then write the actual .htaccess file to a temporary directory which is about to be upload to the web hosting account.</p>
<p>The temporary directory is defined below</p>
<blockquote><p><code>$source = "/opt/tmp/sync-htaccess<strong>/</strong>";</code></p></blockquote>
<p>Make sure there is a <strong>ending slash &#8216;/&#8217; </strong></p>
<p>Also Make sure the directory is existed, otherwise, create it </p>
<blockquote><p><code># mkdir /opt/tmp/sync-htaccess</code></p></blockquote>
<p>** This is the only directory to be synchronized to the web hosting account. So all outputed .htaccess file MUST generated under this directory.</p>
<p>The .htaccess file generated is defined below</p>
<blockquote><p><code><br />
$site1output="/opt/tmp/sync-htaccess/.htaccess";<br />
</code></p></blockquote>
<p>Once the htaccess files is generated, the script will fork to the shell and upload the htaccess files by rsync over ssh. In order to perform the upload task password-less, the script required to read the private ssh key of the web hosting account.</p>
<blockquote><p><code>$sshkey = "/volume1/private/id_rsa";</code></p></blockquote>
<p>Besides of the ssh key, below are the rest of the ssh parameters</p>
<blockquote><p><code>$sshport = "22";<br />
$accid = "account_id";<br />
$accdomain= "mydomain.com";<br />
</code></p></blockquote>
<p>$sshport defines the SSH port.<br />
$accid defines the web hosting account login ID.<br />
$accdomain defines the domain name of the web hosting account.</p>
<p>Once the ssh things were defined, the last thing to do is to tell the rsync command where to upload the .htaccess, which is usually the public_html directory on the web hosting account.</p>
<blockquote><p><code>$remote = "/home/myaccount/public_html";</code></p></blockquote>
<p>Create a cron job to run the script on NAS say per 5 minutes.</p>
<p># vi /etc/crontab</p>
<blockquote><p>*/5 * * * * root /usr/bin/perl /opt/usr/local/bin/sync-htaccess.pl</p></blockquote>
<p><strong>Sample htaccess template &#8211; htaccess_template</strong></p>
<p>Below is a very simple htaccess template for private wordpress blog.</p>
<blockquote>
<p>order deny,allow<br />
deny from all<br />
allow from @@@DYNAMIC@@@</p>
</blockquote>
<p><strong>Another script for webhosting account &#8211; getip.php (I forgot where I copied this script, thanks to the original author)<br />
</strong></p>
<p>This script should upload to web hosting account.</p>
<blockquote><p>
<code><br />
&lt;?=trim(getip())?&gt;</p>
<p>&lt;?</p>
<p>function validip($ip)<br />
{</p>
<p>if (!empty($ip) &#038;&#038; ip2long($ip)!=-1) {</p>
<p>  $reserved_ips = array (</p>
<p>  array('0.0.0.0','2.255.255.255'),</p>
<p> array('10.0.0.0','10.255.255.255'),</p>
<p> array('127.0.0.0','127.255.255.255'),</p>
<p>array('169.254.0.0','169.254.255.255'),</p>
<p>     array('172.16.0.0','172.31.255.255'),</p>
<p>     array('192.0.2.0','192.0.2.255'),</p>
<p>     array('192.168.0.0','192.168.255.255'),</p>
<p>     array('255.255.255.0','255.255.255.255')</p>
<p>  );</p>
<p>  foreach ($reserved_ips as $r) {</p>
<p>       $min = ip2long($r[0]);</p>
<p>       $max = ip2long($r[1]);</p>
<p>       if ((ip2long($ip) >= $min) &#038;&#038; (ip2long($ip) <= $max))<br />
          return false;</p>
<p>   }<br />
   return true;</p>
<p>} else {</p>
<p>   return false;</p>
<p>}<br />
 ## end if</p>
<p>}<br />
 ## end function</p>
<p>function getip() {</p>
<p>       if (validip($_SERVER["HTTP_CLIENT_IP"])) {</p>
<p>               return $_SERVER["HTTP_CLIENT_IP"];</p>
<p>       }</p>
<p>       foreach (explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) {</p>
<p>               if (validip(trim($ip))) {</p>
<p>                       return $ip;<br />
               }</p>
<p>               if (validip($_SERVER["HTTP_X_FORWARDED"])) {</p>
<p>                       return $_SERVER["HTTP_X_FORWARDED"];<br />
               } elseif (validip($_SERVER["HTTP_FORWARDED_FOR"])) {</p>
<p>                       return $_SERVER["HTTP_FORWARDED_FOR"];<br />
               } elseif (validip($_SERVER["HTTP_FORWARDED"])) {</p>
<p>                       return $_SERVER["HTTP_FORWARDED"];<br />
               } elseif (validip($_SERVER["HTTP_X_FORWARDED"])) {<br />
                       return $_SERVER["HTTP_X_FORWARDED"];<br />
               } else {<br />
                       return $_SERVER["REMOTE_ADDR"];</p>
<p>               }</p>
<p>        }</p>
<p>}</p>
<p>?&gt;<br />
</code>
</p></blockquote>
<p><strong>Conclusion</strong></p>
<p>Here is the files required for the tasks.</p>
<p><strong>Webhost</strong></p>
<ul>
<li>getip.php</li>
</ul>
<p><strong>NAS</strong></p>
<ul>
<li>sync-htaccess.pl</li>
<li>htaccess template</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/05/19/restricting-wordpess-access-by-home-ip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synology usage series 28 – Mirroring wordpress from webhost to synology box &#8211; the automatic way</title>
		<link>http://blog.deadcode.net/2011/05/18/mirroring-wordpress-from-webhost-to-synology/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mirroring-wordpress-from-webhost-to-synology</link>
		<comments>http://blog.deadcode.net/2011/05/18/mirroring-wordpress-from-webhost-to-synology/#comments</comments>
		<pubDate>Wed, 18 May 2011 11:27:16 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Synology]]></category>
		<category><![CDATA[DS207+]]></category>
		<category><![CDATA[Mirroring]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://deadcode.net/?p=2634</guid>
		<description><![CDATA[<p>My previous backup strategy is simple login to cpanel, generate full backup and then ftp it and have it stored in the syno box monthly. The disadvantages is that</p>
<p>-  wasting a lot of local storage to store a number of full backup<br />
-  time consuming to perform these tasks manually and ftping large backup archive periodically.<br />
- Since I&#8217;m only performing backup monthly, data is subject to lost if something funny happened on my webhost account (disk crash, hacker, whatover)</p>
<p>Why not just mirroring the live site to the apache on the syno box? The benefit </p>
<p>- automate all backup tasks without manual procedures<br />
- can backup up to like every 10 minutes or even less<br />
- backup only changes!! not full backup everytime<br />
- incremental backup means saving tons of local storage<br />
- can verify the backup content using any browser because the backup site is  actually running on the NAS!</p>
<p>Since there is no synchronization plugin available for wordpress, I&#8217;m doing this task by a few scripts written myself.</p>
<p><strong>Understanding the sequence</strong></p>
<ol>
<li>Firstly, we setup a virtual domain on our NAS in order to host the mirror site.</li>
<li>We setup a schedule job to backup the wordpress database daily</li>
<li>After the database is backup, a cron job will download the db backup as well as the web files to our NAS</li>
<li>After download, another cron job will extract the backup file and import the data to local mysql database.</li>
<li>Finally, we patch the local data in order to have the wordpress running on the mirror site.</li>
</ol>
<p><strong>The requirement</strong></p>
<p>This article requires a lots of technique mentioned in previous articles, make sure you familiar with the setup below, otherwise, refer to previous articles.</p>
<ul>
<li>Setup ssh public key authentication (usage series 5)</li>
<li>Setup DNS and DDNS (usage series 20)</li>
<li>Data patching</li>
<li>Setup wordpress (usage series 16)</li>
<li>Setup cronjob</li>
</ul>
]]></description>
			<content:encoded><![CDATA[<p>My previous backup strategy is simple login to cpanel, generate full backup and then ftp it and have it stored in the syno box monthly. The disadvantages is that</p>
<p>-  wasting a lot of local storage to store a number of full backup<br />
-  time consuming to perform these tasks manually and ftping large backup archive periodically.<br />
- Since I&#8217;m only performing backup monthly, data is subject to lost if something funny happened on my webhost account (disk crash, hacker, whatover)</p>
<p>Why not just mirroring the live site to the apache on the syno box? The benefit </p>
<p>- automate all backup tasks without manual procedures<br />
- can backup up to like every 10 minutes or even less<br />
- backup only changes!! not full backup everytime<br />
- incremental backup means saving tons of local storage<br />
- can verify the backup content using any browser because the backup site is  actually running on the NAS!</p>
<p>Since there is no synchronization plugin available for wordpress, I&#8217;m doing this task by a few scripts written myself.</p>
<p><strong>Understanding the sequence</strong></p>
<ol>
<li>Firstly, we setup a virtual domain on our NAS in order to host the mirror site.</li>
<li>We setup a schedule job to backup the wordpress database daily</li>
<li>After the database is backup, a cron job will download the db backup as well as the web files to our NAS</li>
<li>After download, another cron job will extract the backup file and import the data to local mysql database.</li>
<li>Finally, we patch the local data in order to have the wordpress running on the mirror site.</li>
</ol>
<p><strong>The requirement</strong></p>
<p>This article requires a lots of technique mentioned in previous articles, make sure you familiar with the setup below, otherwise, refer to previous articles.</p>
<ul>
<li>Setup ssh public key authentication (usage series 5)</li>
<li>Setup DNS and DDNS (usage series 20)</li>
<li>Data patching</li>
<li>Setup wordpress (usage series 16)</li>
<li>Setup cronjob</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadcode.net/2011/05/18/mirroring-wordpress-from-webhost-to-synology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

