using individual Gateways for the Two LAN on Synology NAS

Warning: This article was published many years ago (greater than two) Mar 24, 2013. Some information may be outdated.

Synology NAS has only one default Gateway field in the GUI for Network, hence in case you want the two lan to have its own gateways then the following will do the trick.

Control Pannel > Network > General Tab

Server Name: NAS
Default Gateway: 192.168.1.1

1. configure the LAN 1 “Manual Configuration”

IP Address 192.168.1.10
subNet Mask 255.255.255.0

2. configure the LAN 2 “Manual Configuration”

IP Address 192.168.2.10
subNet Mask 255.255.255.0

3. SSH to the NAS

( enable SSH in Control Panel > Terminal )
open terminal on your PC / Laptop

> ssh root@192.168.1.10
root@192.168.1.10's password: your admin password
NAS>

type the following

NAS> cd /etc/
NAS> vi rc.local
#! /bin/sh
# ip route add IP Address for LAN / Mask via IP Address of Gateway dev eth0 or eth1 
ip route add 192.168.2.0/24 via 192.168.2.1 dev eth1
:wq
NAS> reboot

4. Check if the route is correct

NAS> route -e
Kernel IP routing table
Destination   Gateway        Genmask         Flags MSS Window irtt Iface
default       192.168.1.1    0.0.0.0         UG    0    0     0    eth0
192.168.1.0   *              255.255.255.0   U     0    0     0    eth0
192.168.2.0   192.168.2.1    0.0.0.0         UG    0    0     0    eth1
192.168.2.0   *              255.255.255.0   U     0    0     0    eth1

192.168.1.0/24 will be routed through gateway 192.168.1.1 on LAN 1
192.168.2.0/24 will be routed through gateway 192.168.2.1 on LAN 2

6 Comments

  1. Hi, taks for this great guide, i wrote you because we have a problem in this config. when we insert the 24 for the subnet the settings don’t work, if we don’t set the 24 the settings works on the 255.255.255.255 (thqat cannot be set on the nas). had you same idea?

    • I quite did not understand you question? what is the output of “route -e” if the route is as shown above then you need not worry.. make be synology DSM has broken the chain..

      • if i use
        ip route add 192.168.1.0/24 via 192.168.1.1 dev eth1

        NAS> route -e
        Kernel IP routing table
        Destination Gateway Genmask Flags MSS Window irtt Iface
        default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
        192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
        192.168.2.0 * 255.255.255.0 U 0 0 0 eth1

        If i use
        ip route add 192.168.1.0 via 192.168.1.1 dev eth1

        NAS> route -e
        Kernel IP routing table
        Destination Gateway Genmask Flags MSS Window irtt Iface
        default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
        192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
        192.168.1.0 * 255.255.255.0 U 0 0 0 eth1
        192.168.1.0 192.168.1.1 255.255.255.255 UG 0 0 0 eth1

        Maybe last DSM (5) broke it?

        Thanks for support

  2. This worked for me (DSM 5.0-4482) “Quick and Dirty”:
    Login via SSH as root

    cd /etc/
    vi rc.local
    #!/bin/sh
    route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1
    :w
    :q
    chmod u+x rc.local
    reboot

    (for testing you can also type the command directly to the console, but maybe you’ll lose the settings after reboot)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.