Search This Blog

Friday, 26 September 2014

Add a static route to QNAP NAS

Can't be done via the GUI so you need to use some CLI foo.  You can set a route temporarily via the shell but in order for it to remain persistent you need to edit the startup script.

1 - Connect via ssh to your device
2 - Mount the QNAP Configuration

The name of the actual device to mount depends on your model number. In general for x86-based systems this should be /dev/sdx6. For Marvell ARM based models it should be /dev/mtdblock5 or /dev/mtdblock4.
[~] # mount -t ext2 /dev/sdx6 /tmp/config

2 - Create or adapt autorun.sh

A shell script called “autorun.sh” will be executed by your QNAP storage system on every startup. It might be possible that file currently does not exist so just go ahead and create it with your favorite text editor, or the whatever is installed.
#!/bin/sh
route add -net <subnet> netmask <mask> gw <gw_ip_addr>
3 - Make sure that autorun.sh is executable
In order to be executable during startup, we will have to set the executable flag for “autorun.sh”:
[~] # ls -al /tmp/config/autorun.sh
-rw-r--r--    1 admin    administ       60 May 11 17:43 /tmp/config/autorun.sh*
[~] #
[~] # chmod +x /tmp/config/autorun.sh
[~] #
[~] # ls -al /tmp/config/autorun.sh
-rwxr-xr-x    1 admin    administ       60 May 11 17:43 /tmp/config/autorun.sh*
[~] #
4 - Unmount the config
[~]# Unmount /tmp/config

No comments:

Post a comment