Here is a recap of an old project. following this straight through won’t be enough to redo what I’ve done, but the websites and hints that I followed are linked throughout this post.
I bought a Belkin PlayMax 600HD router from Best Buy because I read in some review that I could do port forwarding (needed to setup my own server at home). Well after a lot of time in the settings and several emails to Belkin it turns out that this feature isn’t built in. So after a friend told me about dd-wrt I decided to give it a shot after reading a lot of forums to see if my router would work. This forum post on dd-wrt.com is about my router.
For the most part I followed the instructions from teh dd-wrt site: http://www.dd-wrt.com/wiki/index.php/Installation
Start by doing a 30/30/30 reset. The text below is copied from the dd-wrt website.
Hard Reset (aka 30/30/30 reset):
The following procedure will clear out the NVRAM and set dd-wrt back to default values:
- With the unit powered on, press and hold the reset button on back of unit for 30 seconds
- Without releasing the reset button, unplug the unit and hold reset for another 30 seconds
- Plug the unit back in STILL holding the reset button a final 30 seconds (please note that this step can put Asus devices into recovery mode…see note below!)
This procedure should be done BEFORE and AFTER every firmware upgrade/downgrade.
Do not use configuration restore if you change firmware builds (different svn build numbers).
I got my files from ftp://ftp.dd-wrt.com/others/eko/V24-K26/
My Router is advised to only use the TFTP: http://www.dd-wrt.com/wiki/index.php/TFTP_flash
First I flashed the 15508 mini and then a 30/30/30 reset. Even though I’m advised to use TFTP I used the webpage GUI to flash the 18946 mega and followed up with a 30/30/30 reset. I’ve found that Firefox has issues with webpage GUI and have reverted to Internet Explorer for all setting changes and flash updates. I actually tried several different version and sizes for my router and sometimes had issues with enabling SSH or other weird things. I even had a problem with the 18946 mega for a while, but after a lot of time trying different things I believe that I simply didn’t get a good flash from either not doing a 30/30/30 reset properly or something else. But in the end the 18946 mega works for me.
In the system settings I now see:
There is a ton of configuring to do that I’m not going to get into because I either don’t remember what I set or I’m concerned about leaking potential security details. Things that I’ve added are Wake up on Lan (WOL) for my media server, SSH is a must to get into the file system from within the network, port forwarding (see below) and sharing the two USB drive connections over the network (see below)
I had a heck of a time getting port forwarding to work for computers within the LAN. Here is a post I placed on the dd-wrt forum about this topic:
Here are several websites that I referenced read and found useful along the way
In the end I added the following to the firewall section in the Administration->Commands section
insmod ipt_mark insmod xt_mark iptables -t mangle -A PREROUTING -i ! `get_wanface` -d `nvram get wan_ipaddr` -j MARK --set-mark 0xd001 iptables -t mangle -A PREROUTING -j CONNMARK --save-mark iptables -t nat -A POSTROUTING -m mark --mark 0xd001 -j MASQUERADE
I’ll have to say I’m not entire sure I understand what is happening, but it works so I’m not complaining. Now I’m able to see this website both internal and external to my network.
NAS USB Drives
I have two 1TB USB drives attached to my router the following are the steps that I took which mostly comes from following this sites instructions which also uses the dd-wrt sites instructions of Optware, the Right Way.
Format the hard drives
(I did this at another time and didn’t record my steps)
Enable USB at Services->USB
and enable the following parameters:
Core USB Support
USB Storage Support
Automatic Drive Mount
Disk Mount Option = /opt
Save then do a reboot
Check Services->USB to see the Optware and Swap loaded
Disk Info --- /dev/discs/disc0/disc Block device, size 931.5 GiB (1000204886016 bytes) DOS/MBR partition map Partition 1: 930.5 GiB (999128297984 bytes, 1951422457 sectors from 2055) Type 0x07 (HPFS/NTFS) NTFS file system Volume size 930.5 GiB (999128297472 bytes, 1951422456 sectors) Partition 2: 1 GiB (1073741824 bytes, 2097152 sectors from 1951424512) Type 0x0F (Win95 Ext'd (LBA)) Partition 5: 767 MiB (804257792 bytes, 1570816 sectors from 1951424512+2048) Type 0x83 (Linux) Ext2 file system Volume name "/Optware" UUID 0A911958-F81C-51AA-E421-3C2F22FBB048 (Reserved) Volume size 767 MiB (804257792 bytes, 196352 blocks of 4 KiB) Partition 6: 255 MiB (267386880 bytes, 522240 sectors from 1952997376+2048) Type 0x82 (Linux swap / Solaris) Linux swap, version 2, subversion 1, 4 KiB pages, little-endian Swap size 255.0 MiB (267378688 bytes, 65278 pages of 4 KiB) Status: Mounted on /opt Status: Not mounted Status: Not mounted Status: Not mounted
Next SSH into the router and verify the /opt partition is mounted
root@BLT_ROUTER:~# mount rootfs on / type rootfs (rw) /dev/root on / type squashfs (ro) none on /dev type devfs (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) ramfs on /tmp type ramfs (rw) devpts on /dev/pts type devpts (rw) devpts on /proc/bus/usb type usbfs (rw) /dev/discs/disc0/part5 on /opt type ext2 (rw,noatime)
Check for router connection to the internet
root@BLT_ROUTER:~# ping google.com PING google.com (126.96.36.199): 56 data bytes 64 bytes from 188.8.131.52: icmp_seq=0 ttl=55 time=17.870 ms 64 bytes from 184.108.40.206: icmp_seq=1 ttl=55 time=17.222 ms --- google.com ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 17.222/17.546/17.870/0.324 ms
Next download the optware prep script
root@BLT_ROUTER:~# wget -O /tmp/prep_optware http://wd.mirmana.com/prep_optware --2012-11-11 21:53:33-- http://wd.mirmana.com/prep_optware Resolving wd.mirmana.com... 220.127.116.11 Connecting to wd.mirmana.com|18.104.22.168|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 25381 (25K) [application/octet-stream] Saving to: `/tmp/prep_optware' 100%[========================================================================================================================================>] 25,381 48.4K/s in 0.5s 2012-11-11 21:53:34 (48.4 KB/s) - `/tmp/prep_optware' saved [25381/25381]
Now run the prep optware script. I choose Y for all questions
root@BLT_ROUTER:~# sh /tmp/prep_optware
Then I did a reboot
Check free space on optware partition
root@BLT_ROUTER:~# df -h Filesystem Size Used Avail Use% Mounted on rootfs 6.3M 6.3M 0 100% / /dev/root 6.3M 6.3M 0 100% / /dev/discs/disc0/part5 755M 360M 359M 51% /opt
Now install Samba 3.5 (or anything greater than Samba 2) so that it works on Windows 7. I followed this for the most part
First, create backups of original files
root@BLT_ROUTER:/opt/etc/samba# cp /opt/etc/samba/smb.conf /opt/etc/samba/smb.conf.copy root@BLT_ROUTER:/opt/etc/samba# cp /opt/etc/init.d/S80samba /opt/etc/init.d/S80samba.copy
Then turn off the existing Samba service
service samba stop service samba off
and then install Samba (I added Samba 3.5
ipkg-opt remove samba2 ipkg-opt install samba35 ipkg-opt install samba35-swat
After doing this I saw an error:
After removing file and starting noticed and error
grep: can't load library 'libpcre.so.1'
I simply ran updates/upgrades to fix the problem
Update OTWR ipkg update ipkg upgrade
Other in some forums had posted the following symbolic link fix, but my update above seemed to do the trick:
ln -s /opt/lib/libpcre.so.1 /opt/lib/libpcre.so.0
With Samba 3.5 now isntalled it is time to get it configured for the USB drives. First check partitions to determine which name to setup the mounts to.
root@BLT_ROUTER:~# more /proc/partitions major minor #blocks name 31 0 192 mtdblock0 31 1 7936 mtdblock1 31 2 6405 mtdblock2 31 3 64 mtdblock3 31 4 128 mtdblock4 8 0 976762584 sda 8 1 975711228 sda1 8 2 1 sda2 8 5 785408 sda5 8 6 261120 sda6 8 16 976762584 sdb 8 17 975699964 sdb1 8 18 1 sdb2 8 21 921600 sdb5 8 22 136192 sdb6
SDA1 and SDB1 are my external 1TB USB drives. Plug in each one one at a time to determine which block size belongs to which harddrive. The following is just another view of the above.
root@BLT_ROUTER:/mnt# fdisk -l Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x4d0b4b49 Device Boot Start End Blocks Id System /dev/sda1 1 121471 975711228+ 7 HPFS/NTFS Partition 1 does not end on cylinder boundary. /dev/sda2 121471 121602 1048576 f W95 Ext'd (LBA) Partition 2 does not end on cylinder boundary. /dev/sda5 121471 121569 785408 83 Linux /dev/sda6 121569 121602 261120 82 Linux swap / Solaris Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x11c21da9 Device Boot Start End Blocks Id System /dev/sdb1 1 121470 975699964+ 7 HPFS/NTFS Partition 1 does not end on cylinder boundary. /dev/sdb2 121470 121602 1059840 f W95 Ext'd (LBA) Partition 2 does not end on cylinder boundary. /dev/sdb5 121470 121585 921600 83 Linux /dev/sdb6 121585 121602 136192 82 Linux swap / Solaris
root@BLT_ROUTER:/tmp# blkid /dev/sda1: UUID="D4DC4E64DC4E414A" LABEL="1TB ExtnDrive" TYPE="ntfs" /dev/sda5: LABEL="/Optware" UUID="0a911958-f81c-51aa-e421-3c2f22fbb048" TYPE="ext2" /dev/sda6: LABEL="Swap" UUID="5d705f77-397f-868e-cf52-545be358059c" TYPE="swap" /dev/sdb1: UUID="FC0C24480C23FBF0" LABEL="BackupDrive" TYPE="ntfs" /dev/sdb5: LABEL="Optware" UUID="9515a4ae-351b-f102-a517-a196dcb45fa8" TYPE="ext2" /dev/sdb6: LABEL="Swap" UUID="1bb9e834-1bf9-d98b-0a1f-d8bac631f5c5" TYPE="swap"
Next, edit /opt/etc/automount to set the USB drives mount point to the desired location, as I didn’t care for the default too much. Leave /opt as is. I changed my USB drive partitions to /tmp/mnt and /tmp/mnt2
root@BLT_ROUTER:/opt/etc# more automount /opt 0a911958-f81c-51aa-e421-3c2f22fbb048 ext2 /tmp/mnt D4DC4E64DC4E414A fuseblk /tmp/mnt2 FC0C24480C23FBF0 fuseblk /tmp/d 9515a4ae-351b-f102-a517-a196dcb45fa8 ext2
Next configure the samba configuration files to include the USB drives. Make sure the workgroup is the same as your windows computers (default is WORKGROUP)
I changed the hosts allow and interfaces lines, though I don’t recall why now
hosts allow = 192.168.0.0/16 10.0.0.0/8 172.16.0.0/12 127.0.0.0/8 interfaces = 192.168.1.1/24 192.168.1.1/255.255.255.0
Enable WINS Support
wins support = yes
Then in the share definitions section I added the text below to assign the Windows share name to the desired path. All the other default shares are commented out.
[BackupDrive] path = /mnt valid users = www-data nobody root public = yes guest ok = yes ;BT read only = no ; writable = yes printable = no force user = root create mask = 0765 [1TBDrive] path = /tmp/mnt2 valid users = www-data nobody root public = yes guest = ok read only = no writable = yes printable = no force user = root create mask = 0765 [homes] valid users = %S read only = no browseable = no [Optware] path =/opt force user = root read only = no guest ok = yes
Save the config file and restart Samba
service samba stop
Everything should be up and going.